File: stacked.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 (104 lines) | stat: -rw-r--r-- 3,306 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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>stacked</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>
    <p>Simple graph:</p>
    <div id="simple_div"></div>
    <p>Stacked graph:</p>
    <div id="stacked_div"></div>
    <p>Simple graph with missing data:</p>
    <div id="simple_missing_div"></div>
    <p>Stacked graph with missing data:</p>
    <div id="stacked_missing_div"></div>
    <p>Stacked graph with many series:</p>
    <div id="stacked_many_div"></div>
    <p>Change selection/highlighting on all graphs:</p>
    <div id="graph_selection_div">
        <select onchange="javascript:setSelection(this.options[this.selectedIndex].value);">
            <option value="" selected></option>
            <option value="0">0</option>
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="30">30</option>
            <option value="40">40</option>
            <option value="50">50</option>
            <option value="60">60</option>
            <option value="70">70</option>
            <option value="80">80</option>
            <option value="90">90</option>
            <option value="99">99</option>
        </select>
    </div>

    <script type="text/javascript"><!--//--><![CDATA[//><!--
    Dygraph.onDOMready(function onDOMready() {
      data = "X,x,100-x\n";
      for (var i = 0; i < 100; i++) {
        data += i + "," + i + "," + (100 - i) + "\n";
      }

      var graphs = [];

      graphs.push(
          new Dygraph(
              document.getElementById("simple_div"),
              data));

      graphs.push(
          new Dygraph(
              document.getElementById("stacked_div"),
              data,
              { stackedGraph: true }));

      missing_data = "X,x,100-x\n";
      for (var i = 0; i < 100; i++) {
        if (i >= 20 && i < 40) {
          missing_data += i + ",," + (100 - i) + "\n";
        } else if (i >= 60 && i < 80) {
          missing_data += i + "," + i + ",\n";
        } else {
          missing_data += i + "," + i + "," + (100 - i) + "\n";
        }
      }

      graphs.push(
          new Dygraph(
              document.getElementById("simple_missing_div"),
              missing_data));

      graphs.push(
          new Dygraph(
              document.getElementById("stacked_missing_div"),
              missing_data,
              { stackedGraph: true }));

      many_data = "X,a,b,c,d,e,100-a,100-b,100-c,100-d,100-e\n";
      for (var i = 0; i < 100; i++) {
        many_data += i + "," + i + "," + i + "," + i + "," + i + "," + i;
        j = 100 - i;
        many_data += "," + j + "," + j + "," + j + "," + j + "," + j;
        many_data += "\n";
      }

      graphs.push(
          new Dygraph(
              document.getElementById("stacked_many_div"),
              many_data,
              { stackedGraph: true }));

      setSelection = function setSelection(row) {
        for (var i = 0; i < graphs.length; i++) {
          graphs[i].setSelection(row ? row : false);
        }
      }
    });
    //--><!]]></script>
  </body>
</html>