remove extra log
[dygraphs.git] / tests / link-interaction.html
CommitLineData
54425b14 1<!DOCTYPE html>
599fb4ad
DV
2<html>
3 <head>
10494b48 4 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
599fb4ad
DV
5 <title>noise</title>
6 <!--[if IE]>
a2b2c3a1 7 <script type="text/javascript" src="../excanvas.js"></script>
599fb4ad 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
599fb4ad
DV
15 </head>
16 <body>
17 <div id="div_g"></div>
18 <b>Zoom:</b>
19 <a href="#" onclick="zoom(3600)">hour</a>
20 <a href="#" onclick="zoom(86400)">day</a>
21 <a href="#" onclick="zoom(604800)">week</a>
22 <a href="#" onclick="zoom(30 * 86400)">month</a>
23 <a href="#" onclick="reset()">full</a>
24 <b>Pan:</b>
25 <a href="#" onclick="pan(-1)">left</a>
26 <a href="#" onclick="pan(+1)">right</a>
27
28 <script type="text/javascript">
29 var r = [ ];
30 var base_time = Date.parse("2008/07/01");
31 var num = 24 * 0.25 * 365;
32 for (var i = 0; i < num; i++) {
33 r.push([ new Date(base_time + i * 3600 * 1000),
34 i + 50 * (i % 60), // line
35 i * (num - i) * 4.0 / num // parabola
36 ]);
37 }
38 var orig_range = [ r[0][0].valueOf(), r[r.length - 1][0].valueOf() ];
39 g = new Dygraph(
40 document.getElementById("div_g"),
41 r, {
42 rollPeriod: 7,
43 // errorBars: true,
44 width: 600,
45 height: 300,
46 labels: ["Date", "a", "b"]
47 }
48 );
49
50 var desired_range = null;
51 function approach_range() {
52 if (!desired_range) return;
53 // go halfway there
54 var range = g.xAxisRange();
55 if (Math.abs(desired_range[0] - range[0]) < 60 &&
56 Math.abs(desired_range[1] - range[1]) < 60) {
57 g.updateOptions({dateWindow: desired_range});
58 // (do not set another timeout.)
59 } else {
60 var new_range;
61 new_range = [0.5 * (desired_range[0] + range[0]),
62 0.5 * (desired_range[1] + range[1])];
63 g.updateOptions({dateWindow: new_range});
64 animate();
65 }
66 }
67 function animate() {
68 setTimeout(approach_range, 50);
69 }
70
71 function zoom(res) {
72 var w = g.xAxisRange();
73 desired_range = [ w[0], w[0] + res * 1000 ];
74 animate();
75 }
76
77 function reset() {
78 desired_range = orig_range;
79 animate();
80 }
81
82 function pan(dir) {
83 var w = g.xAxisRange();
84 var scale = w[1] - w[0];
85 var amount = scale * 0.25 * dir;
86 desired_range = [ w[0] + amount, w[1] + amount ];
87 animate();
88 }
89 </script>
90 </body>
91</html>