Commit | Line | Data |
---|---|---|
4dd0ac55 RV |
1 | <!DOCTYPE html> |
2 | <html> | |
3 | <head> | |
4 | <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9"> | |
5 | <title>Multiple y-axes with valueRange</title> | |
6 | <!--[if IE]> | |
7 | <script type="text/javascript" src="../excanvas.js"></script> | |
8 | <![endif]--> | |
9 | <!-- | |
10 | For production (minified) code, use: | |
11 | <script type="text/javascript" src="dygraph-combined.js"></script> | |
12 | --> | |
13 | <script type="text/javascript" src="../dygraph-dev.js"></script> | |
14 | ||
15 | </head> | |
16 | <body> | |
17 | <h2>Multiple y-axes with valueRange</h2> | |
18 | <p>The same data with both different valueRanges. Two-axis old y[40, 70] valueRange:</p> | |
19 | <div id="demodiv" style="width: 640; height: 350; border: 1px solid black"></div> | |
20 | <p>Two-axis new valueRange y[40, 80] set:</p> | |
21 | <div id="demodiv_one" style="width: 640; height: 350; border: 1px solid black"></div> | |
22 | <p>Two-axis new valueRange y[40, 80] & y2[1e6, 1.2e6] set:</p> | |
23 | <div id="demodiv_two" style="width: 640; height: 350; border: 1px solid black"></div> | |
24 | <script type="text/javascript"> | |
25 | var data = []; | |
26 | for (var i = 1; i <= 100; i++) { | |
27 | var m = "01", d = i; | |
28 | if (d > 31) { m = "02"; d -= 31; } | |
29 | if (m == "02" && d > 28) { m = "03"; d -= 28; } | |
30 | if (m == "03" && d > 31) { m = "04"; d -= 31; } | |
31 | if (d < 10) d = "0" + d; | |
32 | // two series, one with range 1-100, one with range 1-2M | |
33 | data.push([new Date("2010/" + m + "/" + d), | |
34 | i, | |
35 | 100 - i, | |
36 | 1e6 * (1 + i * (100 - i) / (50 * 50)), | |
37 | 1e6 * (2 - i * (100 - i) / (50 * 50))]); | |
38 | } | |
39 | ||
40 | g = new Dygraph( | |
41 | document.getElementById("demodiv"), | |
42 | data, | |
43 | { | |
44 | labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], | |
45 | 'Y3': { | |
46 | axis: { | |
47 | } | |
48 | }, | |
49 | 'Y4': { | |
50 | axis: 'Y3' // use the same y-axis as series Y3 | |
51 | }, | |
52 | valueRange: [40, 70], | |
53 | axes: { | |
54 | y2: { | |
55 | // set axis-related properties here | |
56 | labelsKMB: true | |
57 | } | |
58 | }, | |
59 | ylabel: 'Primary y-axis', | |
60 | y2label: 'Secondary y-axis', | |
61 | yAxisLabelWidth: 60 | |
62 | } | |
63 | ); | |
64 | ||
65 | g2 = new Dygraph( | |
66 | document.getElementById("demodiv_one"), | |
67 | data, | |
68 | { | |
69 | labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], | |
70 | 'Y3': { | |
71 | axis: { | |
72 | } | |
73 | }, | |
74 | 'Y4': { | |
75 | axis: 'Y3' // use the same y-axis as series Y3 | |
76 | }, | |
77 | axes: { | |
78 | y: { | |
79 | valueRange: [40, 80] | |
80 | }, | |
81 | y2: { | |
82 | // set axis-related properties here | |
83 | labelsKMB: true | |
84 | } | |
85 | }, | |
86 | ylabel: 'Primary y-axis', | |
87 | y2label: 'Secondary y-axis', | |
88 | yAxisLabelWidth: 60 | |
89 | } | |
90 | ); | |
91 | ||
92 | g2 = new Dygraph( | |
93 | document.getElementById("demodiv_two"), | |
94 | data, | |
95 | { | |
96 | labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], | |
97 | 'Y3': { | |
98 | axis: { | |
99 | } | |
100 | }, | |
101 | 'Y4': { | |
102 | axis: 'Y3' // use the same y-axis as series Y3 | |
103 | }, | |
104 | axes: { | |
105 | y: { | |
106 | valueRange: [40, 80] | |
107 | }, | |
108 | y2: { | |
109 | // set axis-related properties here | |
110 | valueRange: [1e6, 1.2e6], | |
111 | labelsKMB: true | |
112 | } | |
113 | }, | |
114 | ylabel: 'Primary y-axis', | |
115 | y2label: 'Secondary y-axis', | |
116 | yAxisLabelWidth: 60 | |
117 | } | |
118 | ); | |
119 | ||
120 | ||
121 | </script> | |
122 | </body> | |
123 | </html> |