File: zoom.html

package info (click to toggle)
dygraphs 2.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,340 kB
  • sloc: javascript: 24,842; sh: 800; python: 581; makefile: 45
file content (114 lines) | stat: -rw-r--r-- 4,443 bytes parent folder | download | duplicates (2)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>zoom</title>

    <link rel="stylesheet" type="text/css" href="../dist/dygraph.css" />
    <link rel="stylesheet" type="text/css" href="../common/vextlnk.css" />
    <script type="text/javascript" src="../dist/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 style="float: right">
        <p>Zoomed: <span id="zoomed">False</span></p>
        <p>Zoomed X: <span id="zoomedX">False</span></p>
        <p>Zoomed Y: <span id="zoomedY">False</span></p>
    </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> <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> <br>
      <input type="button" value="Unzoom" onclick="unzoomGraph()"> 
      <br> <br>
      <input type="button" value="pan frame null" onclick="panEdgeFraction(null)"> 
      <input type="button" value="pan frame 0.1" onclick="panEdgeFraction(0.1)"> 
      <input type="button" value="pan frame 0.5" onclick="panEdgeFraction(0.5)"> 
      </p>

    <script type="text/javascript"><!--//--><![CDATA[//><!--
    Dygraph.onDOMready(function onDOMready() {
      g = new Dygraph(
            document.getElementById("div_g"),
            NoisyData, {
              errorBars: true,
              zoomCallback: function(minDate, maxDate, yRange) {
                showDimensions(minDate, maxDate, yRange);
              },
              drawCallback: function() {
                document.getElementById("zoomed").innerHTML = "" + this.isZoomed();
                document.getElementById("zoomedX").innerHTML = "" + this.isZoomed("x");
                document.getElementById("zoomedY").innerHTML = "" + this.isZoomed("y");
              }
            }
          );

      // 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, yRanges) {
        showXDimensions(minDate, maxDate);
        showYDimensions(yRanges);
      }

      function showXDimensions(first, second) {
        var elem = document.getElementById("xdimensions");
        elem.innerHTML = "dateWindow : [" + first + ", "+ second + "]";
      }

      function showYDimensions(ranges) {
        var elem = document.getElementById("ydimensions");
        elem.innerHTML = "valueRange : [" + ranges + "]";
      }

      zoomGraphX = function zoomGraphX(minDate, maxDate) {
        g.updateOptions({
          dateWindow: [minDate, maxDate]
        });
        showXDimensions(minDate, maxDate);
      }

      zoomGraphY = function zoomGraphY(minValue, maxValue) {
        g.updateOptions({
          valueRange: [minValue, maxValue]
        });
        showYDimensions(g.yAxisRanges());
      }

      unzoomGraph = function unzoomGraph() {
        g.updateOptions({
          dateWindow: null,
          valueRange: null
        });
      }

      panEdgeFraction = function panEdgeFraction(value) {
        g.updateOptions({ panEdgeFraction : value });
      }
    });
    //--><!]]></script>
  </body>
</html>