Commit | Line | Data |
---|---|---|
8b83c6cc RK |
1 | <html> |
2 | <head> | |
937029df | 3 | <title>zoom</title> |
8b83c6cc | 4 | <!--[if IE]> |
e1fb3740 | 5 | <script type="text/javascript" src="../excanvas.js"></script> |
8b83c6cc RK |
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> |
45f2c689 NN |
19 | <div style="float: right"> |
20 | <p>Zoomed: <span id="zoomed">False</span><p/> | |
21 | <p>Zoomed X: <span id="zoomedX">False</span><p/> | |
22 | <p>Zoomed Y: <span id="zoomedY">False</span><p/> | |
23 | </div> | |
8b83c6cc RK |
24 | <div id="div_g" style="width:600px; height:300px;"></div> |
25 | ||
45f2c689 | 26 | |
8b83c6cc RK |
27 | <p><b>Zoom operations:</b></p> |
28 | <p> | |
437c0979 RK |
29 | <input type="button" value="Y (3,5)" onclick="zoomGraphY(3,5)"> |
30 | <input type="button" value="Y (0,4)" onclick="zoomGraphY(0,4)"> | |
31 | <input type="button" value="Y (2,4)" onclick="zoomGraphY(2,4)"> | |
32 | <input type="button" value="Y (0,2)" onclick="zoomGraphY(0,2)"> | |
937029df | 33 | <input type="button" value="Y (0,1)" onclick="zoomGraphY(0,1)"> |
437c0979 RK |
34 | <br> |
35 | <input type="button" value="Oct 8-13" onclick="zoomGraphX(1160261979962, 1163905694248)"> | |
36 | <input type="button" value="Oct 22-28" onclick="zoomGraphX(1161489164461 , 1162008465957)"> | |
37 | <input type="button" value="Oct 23-24" onclick="zoomGraphX(1161575878860, 1161660991675)"> | |
38 | <input type="button" value="Oct 26 6AM-noon" onclick="zoomGraphX(1161770537840, 1161792063332)"> | |
39 | <br> | |
40 | <input type="button" value="Unzoom" onclick="unzoomGraph()"> | |
8b83c6cc RK |
41 | </p> |
42 | ||
43 | ||
44 | <script type="text/javascript"> | |
45 | g = new Dygraph( | |
46 | document.getElementById("div_g"), | |
47 | NoisyData, { | |
a6cc9f3e | 48 | errorBars: true, |
f0f2aef6 RK |
49 | zoomCallback : function(minDate, maxDate, yRange) { |
50 | showDimensions(minDate, maxDate, yRange); | |
45f2c689 NN |
51 | }, |
52 | drawCallback: function(me, initial) { | |
57baab03 NN |
53 | document.getElementById("zoomed").innerHTML = "" + me.isZoomed(); |
54 | document.getElementById("zoomedX").innerHTML = "" + me.isZoomed("x"); | |
55 | document.getElementById("zoomedY").innerHTML = "" + me.isZoomed("y"); | |
45f2c689 | 56 | } |
8b83c6cc RK |
57 | } |
58 | ); | |
59 | ||
60 | // TODO(konigsberg): Implement a visualization that verifies that initial | |
61 | // displays also show correctly. | |
62 | ||
63 | // Pull an initial value for logging. | |
64 | var minDate = g.xAxisRange()[0]; | |
65 | var maxDate = g.xAxisRange()[1]; | |
66 | var minValue = g.yAxisRange()[0]; | |
67 | var maxValue = g.yAxisRange()[1]; | |
dea5c743 | 68 | showDimensions(minDate, maxDate, [minValue, maxValue]); |
8b83c6cc | 69 | |
dea5c743 | 70 | function showDimensions(minDate, maxDate, yRanges) { |
90b15133 | 71 | showXDimensions(minDate, maxDate); |
885c13e4 | 72 | showYDimensions(yRanges); |
c65f2303 RK |
73 | } |
74 | ||
75 | function showXDimensions(first, second) { | |
76 | var elem = document.getElementById("xdimensions"); | |
77 | elem.innerHTML = "dateWindow : [" + first + ", "+ second + "]"; | |
78 | } | |
79 | ||
5f3b823b | 80 | function showYDimensions(ranges) { |
c65f2303 | 81 | var elem = document.getElementById("ydimensions"); |
5f3b823b | 82 | elem.innerHTML = "valueRange : [" + ranges + "]"; |
8b83c6cc RK |
83 | } |
84 | ||
437c0979 | 85 | function zoomGraphX(minDate, maxDate) { |
c65f2303 RK |
86 | g.updateOptions({ |
87 | dateWindow: [minDate, maxDate] | |
88 | }); | |
90b15133 | 89 | showXDimensions(minDate, maxDate); |
437c0979 RK |
90 | } |
91 | ||
92 | function zoomGraphY(minValue, maxValue) { | |
c65f2303 RK |
93 | g.updateOptions({ |
94 | valueRange: [minValue, maxValue] | |
95 | }); | |
f99d913c | 96 | showYDimensions(g.yAxisRanges()); |
437c0979 RK |
97 | } |
98 | ||
99 | function unzoomGraph() { | |
c65f2303 | 100 | g.updateOptions({ |
eeab5025 RK |
101 | dateWindow: null, |
102 | valueRange: null | |
c65f2303 | 103 | }); |
8b83c6cc RK |
104 | } |
105 | </script> | |
106 | ||
107 | </body> | |
108 | </html> |