2 * @fileoverview Tests for the highlightSeriesBackgroundAlpha and highlightSeriesBackgroundColor options.
3 * @author sergeyslepian@gmail.com
6 describe("highlight-series-background", function() {
8 beforeEach(function () {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 afterEach(function () {
15 function setupGraph(highlightSeriesBackgroundAlpha
, highlightSeriesBackgroundColor
) {
21 highlightSeriesOpts
: {
24 highlightCircleSize
: 1
28 if(highlightSeriesBackgroundAlpha
!== undefined
) opts
.highlightSeriesBackgroundAlpha
= highlightSeriesBackgroundAlpha
;
29 if(highlightSeriesBackgroundColor
!== undefined
) opts
.highlightSeriesBackgroundColor
= highlightSeriesBackgroundColor
;
32 for (var j
= 0; j
< 10; j
++) {
36 var graph
= document
.getElementById("graph");
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(undefined
, '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]);