4 name
: 'Highlight Closest Series',
5 title
: 'Interactive closest-series highlighting',
6 setup
: function(parent
) {
7 parent
.innerHTML
= "<div id='demo'></div>";
10 var getData
= function(numSeries
, numRows
, isStacked
) {
13 for (var j
= 0; j
< numRows
; ++j
) {
16 for (var i
= 0; i
< numSeries
; ++i
) {
18 for (var j
= 0; j
< numRows
; ++j
) {
22 val
+= Math
.random() - 0.5;
30 var makeGraph
= function(className
, numSeries
, numRows
, isStacked
) {
31 var demo
= document
.getElementById('demo');
32 var div
= document
.createElement('div');
33 div
.className
= className
;
34 div
.style
.display
= 'inline-block';
35 div
.style
.margin
= '4px';
36 demo
.appendChild(div
);
39 for (var i
= 0; i
< numSeries
; ++i
) {
41 label
= 's' + '000'.substr(label
.length
) + label
;
42 labels
[i
+ 1] = label
;
46 getData(numSeries
, numRows
, isStacked
),
50 labels
: labels
.slice(),
51 stackedGraph
: isStacked
,
53 highlightCircleSize
: 2,
55 strokeBorderWidth
: isStacked
? null : 1,
57 highlightSeriesOpts
: {
60 highlightCircleSize
: 5,
63 var onclick
= function(ev
) {
64 if (g
.isSeriesLocked()) {
67 g
.setSelection(g
.getSelection(), g
.getHighlightSeries(), true);
70 g
.updateOptions({clickCallback
: onclick
}, true);
71 g
.setSelection(false, 's005');
75 makeGraph("few", 20, 50, false);
76 makeGraph("few", 10, 20, true);
77 makeGraph("many", 75, 50, false);
78 makeGraph("many", 40, 50, true);