6 For production (minified) code, use:
7 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
9 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
13 <div id=
"div_g"></div>
15 <a href=
"#" onclick=
"zoom(3600)">hour
</a>
16 <a href=
"#" onclick=
"zoom(86400)">day
</a>
17 <a href=
"#" onclick=
"zoom(604800)">week
</a>
18 <a href=
"#" onclick=
"zoom(30 * 86400)">month
</a>
19 <a href=
"#" onclick=
"reset()">full
</a>
21 <a href=
"#" onclick=
"pan(-1)">left
</a>
22 <a href=
"#" onclick=
"pan(+1)">right
</a>
24 <script type=
"text/javascript">
26 var base_time = Date.parse(
"2008/07/01");
27 var num =
24 *
0.25 *
365;
28 for (var i =
0; i < num; i++) {
29 r.push([ new Date(base_time + i *
3600 *
1000),
30 i +
50 * (i %
60), // line
31 i * (num - i) *
4.0 / num // parabola
34 var orig_range = [ r[
0][
0].valueOf(), r[r.length -
1][
0].valueOf() ];
36 document.getElementById(
"div_g"),
43 labels: [
"Date",
"a",
"b"]
47 var desired_range = null;
48 function approach_range() {
49 if (!desired_range) return;
51 var range = g.xAxisRange();
52 if (Math.abs(desired_range[
0] - range[
0]) <
60 &&
53 Math.abs(desired_range[
1] - range[
1]) <
60) {
54 g.updateOptions({dateWindow: desired_range});
55 // (do not set another timeout.)
58 new_range = [
0.5 * (desired_range[
0] + range[
0]),
59 0.5 * (desired_range[
1] + range[
1])];
60 g.updateOptions({dateWindow: new_range});
65 setTimeout(approach_range,
50);
69 var w = g.xAxisRange();
70 desired_range = [ w[
0], w[
0] + res *
1000 ];
75 desired_range = orig_range;
80 var w = g.xAxisRange();
81 var scale = w[
1] - w[
0];
82 var amount = scale *
0.25 * dir;
83 desired_range = [ w[
0] + amount, w[
1] + amount ];