4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>Multiple y-axes
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
10 For production (minified) code, use:
11 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
13 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
17 <h2>Multiple y-axes
</h2>
18 <p>The same data with both one and two y-axes. Two y-axes:
</p>
19 <p>Two y-axes with y as primary axis (default):
</p>
20 <div id=
"demodiv" style=
"width: 640; height: 350; border: 1px solid black"></div>
21 <p>Two y-axes with y2 as primary axis:
</p>
22 <div id=
"demodiv_y2_primary" style=
"width: 640; height: 350; border: 1px solid black"></div>
23 <p>Two y-axes using different grids:
</p>
24 <div id=
"demodiv_two_grids" style=
"width: 640; height: 350; border: 1px solid black"></div>
25 <p>A single y-axis (left):
</p>
26 <div id=
"demodiv_one" style=
"width: 640; height: 350; border: 1px solid black"></div>
27 <p>A single y-axis (right):
</p>
28 <div id=
"demodiv_one_right" style=
"width: 640; height: 350; border: 1px solid black"></div>
30 <script type=
"text/javascript">
32 for (var i =
1; i <=
100; i++) {
34 if (d
> 31) { m =
"02"; d -=
31; }
35 if (m ==
"02" && d
> 28) { m =
"03"; d -=
28; }
36 if (m ==
"03" && d
> 31) { m =
"04"; d -=
31; }
37 if (d <
10) d =
"0" + d;
38 // two series, one with range
1-
100, one with range
1-
2M
39 data.push([new Date(
"2010/" + m +
"/" + d),
42 1e6 * (
1 + i * (
100 - i) / (
50 *
50)),
43 1e6 * (
2 - i * (
100 - i) / (
50 *
50))]);
47 document.getElementById(
"demodiv"),
50 labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
56 axis: 'Y3' // use the same y-axis as series Y3
60 // set axis-related properties here
64 ylabel: 'Primary y-axis',
65 y2label: 'Secondary y-axis',
71 document.getElementById(
"demodiv_y2_primary"),
74 labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
75 ylabel: 'Primary y-axis',
76 y2label: 'Secondary y-axis',
87 // set axis-related properties here
89 independentTicks: false
92 // set axis-related properties here
95 independentTicks: true
102 document.getElementById(
"demodiv_two_grids"),
105 labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
106 ylabel: 'Primary y-axis',
107 y2label: 'Secondary y-axis',
118 // set axis-related properties here
121 independentTicks: true,
122 gridLinePattern: [
2,
2]
129 document.getElementById(
"demodiv_one"),
132 labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
134 ylabel: 'Primary y-axis',
135 y2label: 'Secondary y-axis',
140 document.getElementById(
"demodiv_one_right"),
143 labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
144 ylabel: 'Primary y-axis',
145 y2label: 'Secondary y-axis',
162 // set axis-related properties here
164 independentTicks: false
167 // set axis-related properties here
170 independentTicks: true
176 function update(el) {
177 g.updateOptions( { fillGraph: el.checked } );
178 g2.updateOptions( { fillGraph: el.checked } );
179 g3.updateOptions( { fillGraph: el.checked } );
180 g4.updateOptions( { fillGraph: el.checked } );
181 g5.updateOptions( { fillGraph: el.checked } );
185 <input type=checkbox
id=
"check" onChange=
"update(this)"><label for=
"check"> Fill?
</label>