File: series-highlight.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 (85 lines) | stat: -rw-r--r-- 2,171 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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Series highlighting</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>

    <style type='text/css'>
      .few .dygraph-legend > span.highlight { border: 1px solid grey; }
      .many .dygraph-legend > span { display: none; }
      .many .dygraph-legend > span.highlight { display: inline; }
    </style>
  </head>
  <body>
    <h2>Series highlighting demo</h2>
<script type="text/javascript"><!--//--><![CDATA[//><!--
Dygraph.onDOMready(function onDOMready() {

var getData = function(numSeries, numRows, isStacked) {
  var data = [];

  for (var j = 0; j < numRows; ++j) {
    data[j] = [j];
  }
  for (var i = 0; i < numSeries; ++i) {
    var val = 0;
    for (var j = 0; j < numRows; ++j) {
      if (isStacked) {
        val = Math.random();
      } else {
        val += Math.random() - 0.5;
      }
      data[j][i + 1] = val;
    }
  }
  return data;
};

var makeGraph = function(className, numSeries, numRows, isStacked) {
  var div = document.createElement('div');
  div.className = className;
  div.style.display = 'inline-block';
  document.body.appendChild(div);

  var labels = ['x'];
  for (var i = 0; i < numSeries; ++i) {
    var label = '' + i;
    label = 's' + '000'.substr(label.length) + label;
    labels[i + 1] = label;
  }
  var g = new Dygraph(
      div,
      getData(numSeries, numRows, isStacked),
      {
        width: 480,
        height: 320,
        labels: labels.slice(),
        stackedGraph: isStacked,

        highlightCircleSize: 2,
        strokeWidth: 1,
        strokeBorderWidth: isStacked ? null : 1,

        highlightSeriesOpts: {
          strokeWidth: 3,
          strokeBorderWidth: 1,
          highlightCircleSize: 5,
        },
      });
  g.setSelection(false, 's005');
  //console.log(g);
};

makeGraph("few", 20, 50, false);
makeGraph("few", 10, 20, true);
makeGraph("many", 75, 50, false);
makeGraph("many", 40, 50, true);

});
//--><!]]></script>
  </body>
</html>