Commit | Line | Data |
---|---|---|
54425b14 | 1 | <!DOCTYPE html> |
8b83c6cc RK |
2 | <html> |
3 | <head> | |
10494b48 | 4 | <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9"> |
937029df | 5 | <title>zoom</title> |
8b83c6cc | 6 | <!--[if IE]> |
e1fb3740 | 7 | <script type="text/javascript" src="../excanvas.js"></script> |
8b83c6cc RK |
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 | <script type="text/javascript" src="data.js"></script> | |
14 | </head> | |
15 | <body> | |
437c0979 | 16 | <h3>Click the buttons to change the zoom level or just use the normal |
447254de | 17 | click-and drag. While zoom typically works by click-and-drag, the |
c65f2303 | 18 | buttons are useful for testing.</h3> |
8b83c6cc | 19 | <h4>Window coordinates (in dates and values):</h4> |
c65f2303 | 20 | <div id="xdimensions"></div> <div id="ydimensions"></div> |
45f2c689 NN |
21 | <div style="float: right"> |
22 | <p>Zoomed: <span id="zoomed">False</span><p/> | |
23 | <p>Zoomed X: <span id="zoomedX">False</span><p/> | |
24 | <p>Zoomed Y: <span id="zoomedY">False</span><p/> | |
25 | </div> | |
8b83c6cc RK |
26 | <div id="div_g" style="width:600px; height:300px;"></div> |
27 | ||
45f2c689 | 28 | |
8b83c6cc RK |
29 | <p><b>Zoom operations:</b></p> |
30 | <p> | |
437c0979 RK |
31 | <input type="button" value="Y (3,5)" onclick="zoomGraphY(3,5)"> |
32 | <input type="button" value="Y (0,4)" onclick="zoomGraphY(0,4)"> | |
33 | <input type="button" value="Y (2,4)" onclick="zoomGraphY(2,4)"> | |
34 | <input type="button" value="Y (0,2)" onclick="zoomGraphY(0,2)"> | |
937029df | 35 | <input type="button" value="Y (0,1)" onclick="zoomGraphY(0,1)"> |
4cac8c7a | 36 | <br> <br> |
437c0979 RK |
37 | <input type="button" value="Oct 8-13" onclick="zoomGraphX(1160261979962, 1163905694248)"> |
38 | <input type="button" value="Oct 22-28" onclick="zoomGraphX(1161489164461 , 1162008465957)"> | |
39 | <input type="button" value="Oct 23-24" onclick="zoomGraphX(1161575878860, 1161660991675)"> | |
40 | <input type="button" value="Oct 26 6AM-noon" onclick="zoomGraphX(1161770537840, 1161792063332)"> | |
4cac8c7a | 41 | <br> <br> |
437c0979 | 42 | <input type="button" value="Unzoom" onclick="unzoomGraph()"> |
4cac8c7a | 43 | <br> <br> |
9ec21d0a | 44 | <input type="button" value="pan frame null" onclick="panEdgeFraction(null)"> |
965a030e RK |
45 | <input type="button" value="pan frame 0.1" onclick="panEdgeFraction(0.1)"> |
46 | <input type="button" value="pan frame 0.5" onclick="panEdgeFraction(0.5)"> | |
8b83c6cc RK |
47 | </p> |
48 | ||
49 | ||
50 | <script type="text/javascript"> | |
51 | g = new Dygraph( | |
52 | document.getElementById("div_g"), | |
53 | NoisyData, { | |
a6cc9f3e | 54 | errorBars: true, |
f0f2aef6 RK |
55 | zoomCallback : function(minDate, maxDate, yRange) { |
56 | showDimensions(minDate, maxDate, yRange); | |
45f2c689 NN |
57 | }, |
58 | drawCallback: function(me, initial) { | |
57baab03 NN |
59 | document.getElementById("zoomed").innerHTML = "" + me.isZoomed(); |
60 | document.getElementById("zoomedX").innerHTML = "" + me.isZoomed("x"); | |
61 | document.getElementById("zoomedY").innerHTML = "" + me.isZoomed("y"); | |
45f2c689 | 62 | } |
8b83c6cc RK |
63 | } |
64 | ); | |
65 | ||
66 | // TODO(konigsberg): Implement a visualization that verifies that initial | |
67 | // displays also show correctly. | |
68 | ||
69 | // Pull an initial value for logging. | |
70 | var minDate = g.xAxisRange()[0]; | |
71 | var maxDate = g.xAxisRange()[1]; | |
72 | var minValue = g.yAxisRange()[0]; | |
73 | var maxValue = g.yAxisRange()[1]; | |
dea5c743 | 74 | showDimensions(minDate, maxDate, [minValue, maxValue]); |
8b83c6cc | 75 | |
dea5c743 | 76 | function showDimensions(minDate, maxDate, yRanges) { |
90b15133 | 77 | showXDimensions(minDate, maxDate); |
885c13e4 | 78 | showYDimensions(yRanges); |
c65f2303 RK |
79 | } |
80 | ||
81 | function showXDimensions(first, second) { | |
82 | var elem = document.getElementById("xdimensions"); | |
83 | elem.innerHTML = "dateWindow : [" + first + ", "+ second + "]"; | |
84 | } | |
85 | ||
5f3b823b | 86 | function showYDimensions(ranges) { |
c65f2303 | 87 | var elem = document.getElementById("ydimensions"); |
5f3b823b | 88 | elem.innerHTML = "valueRange : [" + ranges + "]"; |
8b83c6cc RK |
89 | } |
90 | ||
437c0979 | 91 | function zoomGraphX(minDate, maxDate) { |
c65f2303 RK |
92 | g.updateOptions({ |
93 | dateWindow: [minDate, maxDate] | |
94 | }); | |
90b15133 | 95 | showXDimensions(minDate, maxDate); |
437c0979 RK |
96 | } |
97 | ||
98 | function zoomGraphY(minValue, maxValue) { | |
c65f2303 RK |
99 | g.updateOptions({ |
100 | valueRange: [minValue, maxValue] | |
101 | }); | |
f99d913c | 102 | showYDimensions(g.yAxisRanges()); |
437c0979 RK |
103 | } |
104 | ||
105 | function unzoomGraph() { | |
c65f2303 | 106 | g.updateOptions({ |
eeab5025 RK |
107 | dateWindow: null, |
108 | valueRange: null | |
c65f2303 | 109 | }); |
8b83c6cc | 110 | } |
4cac8c7a | 111 | |
965a030e RK |
112 | function panEdgeFraction(value) { |
113 | g.updateOptions({ panEdgeFraction : value }); | |
4cac8c7a | 114 | } |
8b83c6cc RK |
115 | </script> |
116 | ||
117 | </body> | |
118 | </html> |