2 * @fileoverview Tests for the highlightSeriesBackgroundAlpha and
3 * highlightSeriesBackgroundColor options.
4 * @author sergeyslepian@gmail.com
7 import Dygraph from
'../../src/dygraph';
8 import * as utils from
'../../src/dygraph-utils';
9 import Util from
'./Util';
11 describe("highlight-series-background", function() {
15 function setupGraph(highlightSeriesBackgroundAlpha
,
16 highlightSeriesBackgroundColor
) {
22 highlightSeriesOpts
: {
25 highlightCircleSize
: 1
29 if (highlightSeriesBackgroundAlpha
) utils
.update(opts
, {highlightSeriesBackgroundAlpha
});
30 if (highlightSeriesBackgroundColor
) utils
.update(opts
, {highlightSeriesBackgroundColor
});
33 for (var j
= 0; j
< 10; j
++) {
37 return new Dygraph('graph', data
, opts
);
40 it('testDefaultHighlight', function(done
) {
41 var graph
= setupGraph();
43 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
45 graph
.setSelection(0, 'y', true);
47 // handle background color fade-in time
48 setTimeout(function() {
49 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [255,255,255,127]);
54 it('testNoHighlight', function(done
) {
55 var graph
= setupGraph(1);
57 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
59 graph
.setSelection(0, 'y', true);
61 // handle background color fade-in time
62 setTimeout(function() {
63 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
68 it('testCustomHighlightColor', function(done
) {
69 var graph
= setupGraph(null, 'rgb(0,255,255)');
71 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
73 graph
.setSelection(0, 'y', true);
75 // handle background color fade-in time
76 setTimeout(function() {
77 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,255,255,127]);
82 it('testCustomHighlightAlpha', function(done
) {
83 var graph
= setupGraph(0.3);
85 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
87 graph
.setSelection(0, 'y', true);
89 // handle background color fade-in time
90 setTimeout(function() {
91 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [255,255,255,179]);
96 it('testCustomHighlightColorAndAlpha', function(done
) {
97 var graph
= setupGraph(0.7,'rgb(255,0,0)');
99 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [0,0,0,0]);
101 graph
.setSelection(0, 'y', true);
103 // handle background color fade-in time
104 setTimeout(function() {
105 assert
.deepEqual(Util
.samplePixel(graph
.canvas_
, 100, 100), [255,0,0,76]);