1 /*global Gallery,Dygraph,data */
5 name
: 'Highlight Closest Series',
6 title
: 'Interactive closest-series highlighting',
7 setup
: function(parent
) {
8 parent
.innerHTML
= "<div id='demo'></div>";
11 var getData
= function(numSeries
, numRows
, isStacked
) {
14 for (var j
= 0; j
< numRows
; ++j
) {
17 for (var i
= 0; i
< numSeries
; ++i
) {
19 for (var j
= 0; j
< numRows
; ++j
) {
23 val
+= Math
.random() - 0.5;
31 var makeGraph
= function(className
, numSeries
, numRows
, isStacked
) {
32 var demo
= document
.getElementById('demo');
33 var div
= document
.createElement('div');
34 div
.className
= className
;
35 div
.style
.display
= 'inline-block';
36 div
.style
.margin
= '4px';
37 demo
.appendChild(div
);
40 for (var i
= 0; i
< numSeries
; ++i
) {
42 label
= 's' + '000'.substr(label
.length
) + label
;
43 labels
[i
+ 1] = label
;
47 getData(numSeries
, numRows
, isStacked
),
51 labels
: labels
.slice(),
52 stackedGraph
: isStacked
,
54 highlightCircleSize
: 2,
56 strokeBorderWidth
: isStacked
? null : 1,
58 highlightSeriesOpts
: {
61 highlightCircleSize
: 5
64 var onclick
= function(ev
) {
65 if (g
.isSeriesLocked()) {
68 g
.setSelection(g
.getSelection(), g
.getHighlightSeries(), true);
71 g
.updateOptions({clickCallback
: onclick
}, true);
72 g
.setSelection(false, 's005');
76 makeGraph("few", 20, 50, false);
77 makeGraph("few", 10, 20, true);
78 makeGraph("many", 75, 50, false);
79 makeGraph("many", 40, 50, true);