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