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