Commit | Line | Data |
---|---|---|
8b83c6cc RK |
1 | <html> |
2 | <head> | |
937029df | 3 | <title>zoom</title> |
8b83c6cc RK |
4 | <!--[if IE]> |
5 | <script type="text/javascript" src="excanvas.js"></script> | |
6 | <![endif]--> | |
7 | <script type="text/javascript" src="../strftime/strftime-min.js"></script> | |
8 | <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script> | |
9 | <script type="text/javascript" src="../dygraph-canvas.js"></script> | |
10 | <script type="text/javascript" src="../dygraph.js"></script> | |
11 | <script type="text/javascript" src="data.js"></script> | |
12 | </head> | |
13 | <body> | |
437c0979 | 14 | <h3>Click the buttons to change the zoom level or just use the normal |
447254de | 15 | click-and drag. While zoom typically works by click-and-drag, the |
c65f2303 | 16 | buttons are useful for testing.</h3> |
8b83c6cc | 17 | <h4>Window coordinates (in dates and values):</h4> |
c65f2303 | 18 | <div id="xdimensions"></div> <div id="ydimensions"></div> |
8b83c6cc RK |
19 | <div id="div_g" style="width:600px; height:300px;"></div> |
20 | ||
21 | <p><b>Zoom operations:</b></p> | |
22 | <p> | |
437c0979 RK |
23 | <input type="button" value="Y (3,5)" onclick="zoomGraphY(3,5)"> |
24 | <input type="button" value="Y (0,4)" onclick="zoomGraphY(0,4)"> | |
25 | <input type="button" value="Y (2,4)" onclick="zoomGraphY(2,4)"> | |
26 | <input type="button" value="Y (0,2)" onclick="zoomGraphY(0,2)"> | |
937029df | 27 | <input type="button" value="Y (0,1)" onclick="zoomGraphY(0,1)"> |
437c0979 RK |
28 | <br> |
29 | <input type="button" value="Oct 8-13" onclick="zoomGraphX(1160261979962, 1163905694248)"> | |
30 | <input type="button" value="Oct 22-28" onclick="zoomGraphX(1161489164461 , 1162008465957)"> | |
31 | <input type="button" value="Oct 23-24" onclick="zoomGraphX(1161575878860, 1161660991675)"> | |
32 | <input type="button" value="Oct 26 6AM-noon" onclick="zoomGraphX(1161770537840, 1161792063332)"> | |
33 | <br> | |
34 | <input type="button" value="Unzoom" onclick="unzoomGraph()"> | |
8b83c6cc RK |
35 | </p> |
36 | ||
37 | ||
38 | <script type="text/javascript"> | |
39 | g = new Dygraph( | |
40 | document.getElementById("div_g"), | |
41 | NoisyData, { | |
2a07b81b | 42 | zoomCallback : function(a,b,c,d) { showDimensions(a,b,c,d); } |
8b83c6cc RK |
43 | } |
44 | ); | |
45 | ||
46 | // TODO(konigsberg): Implement a visualization that verifies that initial | |
47 | // displays also show correctly. | |
48 | ||
49 | // Pull an initial value for logging. | |
50 | var minDate = g.xAxisRange()[0]; | |
51 | var maxDate = g.xAxisRange()[1]; | |
52 | var minValue = g.yAxisRange()[0]; | |
53 | var maxValue = g.yAxisRange()[1]; | |
8b83c6cc RK |
54 | showDimensions(minDate, maxDate, minValue, maxValue); |
55 | ||
56 | function showDimensions(minDate, maxDate, minValue, maxValue) { | |
c65f2303 RK |
57 | showXDimensions(minDate, maxDate); |
58 | showYDimensions(minValue, maxValue); | |
59 | } | |
60 | ||
61 | function showXDimensions(first, second) { | |
62 | var elem = document.getElementById("xdimensions"); | |
63 | elem.innerHTML = "dateWindow : [" + first + ", "+ second + "]"; | |
64 | } | |
65 | ||
66 | function showYDimensions(first, second) { | |
67 | var elem = document.getElementById("ydimensions"); | |
68 | elem.innerHTML = "valueRange : [" + first + ", "+ second + "]"; | |
8b83c6cc RK |
69 | } |
70 | ||
437c0979 | 71 | function zoomGraphX(minDate, maxDate) { |
c65f2303 RK |
72 | g.updateOptions({ |
73 | dateWindow: [minDate, maxDate] | |
74 | }); | |
75 | showXDimensions(minDate, maxDate); | |
437c0979 RK |
76 | } |
77 | ||
78 | function zoomGraphY(minValue, maxValue) { | |
c65f2303 RK |
79 | g.updateOptions({ |
80 | valueRange: [minValue, maxValue] | |
81 | }); | |
82 | showYDimensions(minValue, maxValue); | |
437c0979 RK |
83 | } |
84 | ||
85 | function unzoomGraph() { | |
c65f2303 | 86 | g.updateOptions({ |
eeab5025 RK |
87 | dateWindow: null, |
88 | valueRange: null | |
c65f2303 | 89 | }); |
8b83c6cc RK |
90 | } |
91 | </script> | |
92 | ||
93 | </body> | |
94 | </html> |