add back Dygraph.floatFormat
[dygraphs.git] / tests / stacked.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
5 <title>stacked</title>
6 <!--[if IE]>
7 <script type="text/javascript" src="../excanvas.js"></script>
8 <![endif]-->
9 <script type="text/javascript" src="../strftime/strftime-min.js"></script>
10 <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
11 <script type="text/javascript" src="../dygraph-canvas.js"></script>
12 <script type="text/javascript" src="../dygraph.js"></script>
13 </head>
14 <body>
15 <p>Simple graph:</p>
16 <div id="simple_div"></div>
17 <p>Stacked graph:</p>
18 <div id="stacked_div"></div>
19 <p>Simple graph with missing data:</p>
20 <div id="simple_missing_div"></div>
21 <p>Stacked graph with missing data:</p>
22 <div id="stacked_missing_div"></div>
23 <p>Stacked graph with many series:</p>
24 <div id="stacked_many_div"></div>
25 <p>Change selection/highlighting on all graphs:</p>
26 <div id="graph_selection_div">
27 <select onchange="javascript:setSelection(this.options[this.selectedIndex].value);">
28 <option value="" selected></option>
29 <option value="0">0</option>
30 <option value="10">10</option>
31 <option value="20">20</option>
32 <option value="30">30</option>
33 <option value="40">40</option>
34 <option value="50">50</option>
35 <option value="60">60</option>
36 <option value="70">70</option>
37 <option value="80">80</option>
38 <option value="90">90</option>
39 <option value="99">99</option>
40 </select>
41 </div>
42
43 <script type="text/javascript">
44 data = "X,x,100-x\n";
45 for (var i = 0; i < 100; i++) {
46 data += i + "," + i + "," + (100 - i) + "\n";
47 }
48
49 var graphs = [];
50
51 graphs.push(
52 new Dygraph(
53 document.getElementById("simple_div"),
54 data));
55
56 graphs.push(
57 new Dygraph(
58 document.getElementById("stacked_div"),
59 data,
60 { stackedGraph: true }));
61
62 missing_data = "X,x,100-x\n";
63 for (var i = 0; i < 100; i++) {
64 if (i >= 20 && i < 40) {
65 missing_data += i + ",," + (100 - i) + "\n";
66 } else if (i >= 60 && i < 80) {
67 missing_data += i + "," + i + ",\n";
68 } else {
69 missing_data += i + "," + i + "," + (100 - i) + "\n";
70 }
71 }
72
73 graphs.push(
74 new Dygraph(
75 document.getElementById("simple_missing_div"),
76 missing_data));
77
78 graphs.push(
79 new Dygraph(
80 document.getElementById("stacked_missing_div"),
81 missing_data,
82 { stackedGraph: true }));
83
84 many_data = "X,a,b,c,d,e,100-a,100-b,100-c,100-d,100-e\n";
85 for (var i = 0; i < 100; i++) {
86 many_data += i + "," + i + "," + i + "," + i + "," + i + "," + i;
87 j = 100 - i;
88 many_data += "," + j + "," + j + "," + j + "," + j + "," + j;
89 many_data += "\n";
90 }
91
92 graphs.push(
93 new Dygraph(
94 document.getElementById("stacked_many_div"),
95 many_data,
96 { stackedGraph: true }));
97
98 function setSelection(row) {
99 for (var i = 0; i < graphs.length; i++) {
100 graphs[i].setSelection(row ? row : false);
101 }
102 }
103 </script>
104 </body>
105 </html>