File: two-axes-vr.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 (112 lines) | stat: -rw-r--r-- 3,525 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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Multiple y-axes with valueRange</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>
  </head>
  <body>
    <h2>Multiple y-axes with valueRange</h2>
    <p>The same data with both different valueRanges. Two-axis old y[40, 70] valueRange:</p>
    <div id="demodiv" style="width: 640; height: 350; border: 1px solid black"></div>
    <p>Two-axis new valueRange y[40, 80] set:</p>
    <div id="demodiv_one" style="width: 640; height: 350; border: 1px solid black"></div>
    <p>Two-axis new valueRange y[40, 80] &amp; y2[1e6, 1.2e6] set:</p>
    <div id="demodiv_two" style="width: 640; height: 350; border: 1px solid black"></div>
    <script type="text/javascript"><!--//--><![CDATA[//><!--
    Dygraph.onDOMready(function onDOMready() {
      var data = [];
      for (var i = 1; i <= 100; i++) {
        var m = "01", d = i;
        if (d > 31) { m = "02"; d -= 31; }
        if (m == "02" && d > 28) { m = "03"; d -= 28; }
        if (m == "03" && d > 31) { m = "04"; d -= 31; }
        if (d < 10) d = "0" + d;
        // two series, one with range 1-100, one with range 1-2M
        data.push([new Date("2010/" + m + "/" + d),
                   i,
                   100 - i,
                   1e6 * (1 + i * (100 - i) / (50 * 50)),
                   1e6 * (2 - i * (100 - i) / (50 * 50))]);
      }

      g = new Dygraph(
          document.getElementById("demodiv"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': { axis: 'y2' },
              'Y4': { axis: 'y2' }
            },
            valueRange: [40, 70],
            axes: {
              y2: {
                // set axis-related properties here
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis'
          }
      );

      g2 = new Dygraph(
          document.getElementById("demodiv_one"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': { axis: 'y2' },
              'Y4': { axis: 'y2' }
            },
            axes: {
              y: {
                valueRange: [40, 80]
              },
              y2: {
                // set axis-related properties here
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis',
            axes: {
              y: {
                axisLabelWidth: 60
              }
            }
          }
      );

      g3 = new Dygraph(
          document.getElementById("demodiv_two"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': { axis: 'y2' },
              'Y4': { axis: 'y2' }
            },
            axes: {
              y: {
                valueRange: [40, 80],
                axisLabelWidth: 60
              },
              y2: {
                // set axis-related properties here
                valueRange: [1e6, 1.2e6],
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis'
          }
      );
    });
    //--><!]]></script>
  </body>
</html>