File: connect-separated.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 (64 lines) | stat: -rw-r--r-- 2,357 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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>connect separated</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>Connecting separated points.  All three of the series should have their points
      connected with lines, and hovering over them should produce dot and legend
      overlays in the proper color.</p>

    <div id="graphdiv" style="width:600px; height:300px;"></div>
<p><b>Toggle ConnectSeparated:<b></p>
<p>
  All: <button id="All" onclick="change(this)">true</button>
  Series 1 <button id="Series1" onclick="change(this)">disabled</button>
  Series 2 <button id="Series2" onclick="change(this)">disabled</button>
  Series 3 <button id="Series3" onclick="change(this)">disabled</button>
</p>
    <script type="text/javascript"><!--//--><![CDATA[//><!--
    Dygraph.onDOMready(function onDOMready() {
      g = new Dygraph(document.getElementById("graphdiv"),
      [
        [ new Date("2009/12/01"), 10, 10, 10],
        [ new Date("2009/12/02"), 15, 11, 12],
        [ new Date("2009/12/03"), null, null, 12],
        [ new Date("2009/12/04"), 20, 14, null],
        [ new Date("2009/12/05"), 15, null, 17],
        [ new Date("2009/12/06"), 18, null, null],
        [ new Date("2009/12/07"), 12, 14, null]
      ],
      {
        connectSeparatedPoints: true,
        labels: ["Date","Series1","Series2","Series3"]
      });
    });

      function change(el) {
        var textSequences = [ "disabled", "true", "false" ];
        var values = [ null, true, false ];
        for (var idx = 0; idx < textSequences.length; idx++) {
          if (textSequences[idx] == el.textContent) {
            var nextIdx = (idx + 1) % 3;
            var nextVal = values[nextIdx];
            el.textContent = textSequences[nextIdx];

            if (el.id == "All") {
              g.updateOptions({ connectSeparatedPoints : nextVal });
            } else {
              var seriesOpt = {};
              seriesOpt[el.id] = { connectSeparatedPoints : nextVal };
              g.updateOptions({ series : seriesOpt });
            }
            break;
          }
        }
      }
    //--><!]]></script>
  </body>
</html>