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 makeClickCallback
= function(graph
) {
34 graph
.clearSelection();
37 graph
.setSelection(graph
.getSelection(), graph
.getHighlightSeries(), true);
43 var makeGraph
= function(className
, numSeries
, numRows
, isStacked
) {
44 var demo
= document
.getElementById('demo');
45 var div
= document
.createElement('div');
46 div
.className
= className
;
47 div
.style
.display
= 'inline-block';
48 div
.style
.margin
= '4px';
49 demo
.appendChild(div
);
52 for (var i
= 0; i
< numSeries
; ++i
) {
54 label
= 's' + '000'.substr(label
.length
) + label
;
55 labels
[i
+ 1] = label
;
59 getData(numSeries
, numRows
, isStacked
),
63 labels
: labels
.slice(),
64 stackedGraph
: isStacked
,
66 highlightCircleSize
: 2,
68 strokeBorderWidth
: isStacked
? null : 1,
70 highlightSeriesOpts
: {
73 highlightCircleSize
: 5,
76 g
.updateOptions({clickCallback
: makeClickCallback(g
)}, true);
77 g
.setSelection(false, 's005');
81 makeGraph("few", 20, 50, false);
82 makeGraph("few", 10, 20, true);
83 makeGraph("many", 75, 50, false);
84 makeGraph("many", 40, 50, true);