2 * @fileoverview Tests for per-series options.
4 * @author danvk@google.com (Dan Vanderkam)
7 import Dygraph from
'../../src/dygraph';
9 import PixelSampler from
'./PixelSampler';
11 describe("per-series", function() {
15 it('testPerSeriesFill', function() {
30 Y
: { fillGraph
: true },
32 colors
: [ '#FF0000', '#0000FF' ],
35 var data
= "X,Y,Z\n" +
46 var graph
= document
.getElementById("graph");
47 var g
= new Dygraph(graph
, data
, opts
);
49 var sampler
= new PixelSampler(g
);
51 // Inside of the "Z" bump -- no fill.
52 assert
.deepEqual([0,0,0,0], sampler
.colorAtCoordinate(2.5, 0.5));
54 // Inside of the "Y" bump -- filled in.
55 assert
.deepEqual([255,0,0,38], sampler
.colorAtCoordinate(6.5, 0.5));
58 it('testPerSeriesAlpha', function() {
73 Y
: { fillGraph
: true, fillAlpha
: 0.25 },
74 Z
: { fillGraph
: true, fillAlpha
: 0.75 }
76 colors
: [ '#FF0000', '#0000FF' ]
78 var data
= "X,Y,Z\n" +
89 var graph
= document
.getElementById("graph");
90 var g
= new Dygraph(graph
, data
, opts
);
92 var sampler
= new PixelSampler(g
);
94 // Inside of the "Y" bump -- 5% alpha.
95 assert
.deepEqual([255,0,0,63], sampler
.colorAtCoordinate(6.5, 0.5));
97 // Inside of the "Z" bump -- 95% alpha.
98 assert
.deepEqual([0,0,255,191], sampler
.colorAtCoordinate(2.5, 0.5));
101 it('testNewStyleSeries', function() {
108 var graph
= document
.getElementById("graph");
109 var data
= "X,Y,Z\n1,0,0\n";
110 var g
= new Dygraph(graph
, data
, opts
);
112 assert
.equal(5, g
.getOption("pointSize"));
113 assert
.equal(4, g
.getOption("pointSize", "Y"));
114 assert
.equal(5, g
.getOption("pointSize", "Z"));
117 // TODO(konigsberg): move to multiple_axes.js
118 it('testAxisInNewSeries', function() {
127 var graph
= document
.getElementById("graph");
128 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
129 var g
= new Dygraph(graph
, data
, opts
);
131 assert
.deepEqual(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
132 assert
.deepEqual(["C", "D"], g
.attributes_
.seriesForAxis(1));
135 // TODO(konigsberg): move to multiple_axes.js
136 it('testAxisInNewSeries_withAxes', function() {
145 y
: { pointSize
: 7 },
146 y2
: { pointSize
: 6 }
149 var graph
= document
.getElementById("graph");
150 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
151 var g
= new Dygraph(graph
, data
, opts
);
153 assert
.deepEqual(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
154 assert
.deepEqual(["C", "D"], g
.attributes_
.seriesForAxis(1));
156 assert
.equal(1.5, g
.getOption("pointSize"));
157 assert
.equal(7, g
.getOption("pointSize", "A"));
158 assert
.equal(7, g
.getOption("pointSize", "B"));
159 assert
.equal(6, g
.getOption("pointSize", "C"));
160 assert
.equal(6, g
.getOption("pointSize", "D"));
161 assert
.equal(7, g
.getOption("pointSize", "E"));
164 // TODO(konigsberg): move to multiple_axes.js
165 it('testOldAxisSpecInNewSeriesThrows', function() {
171 var graph
= document
.getElementById("graph");
172 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
175 new Dygraph(graph
, data
, opts
);
180 assert
.isTrue(threw
);
183 it('testColorOption', function() {
184 var graph
= document
.getElementById("graph");
185 var data
= "X,A,B,C\n0,1,2,3\n";
186 var g
= new Dygraph(graph
, data
, {});
187 assert
.deepEqual(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g
.getColors());
188 g
.updateOptions({series
: { B
: { color
: 'purple' }}});
189 assert
.deepEqual(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g
.getColors());