2 * @fileoverview Tests for per-series options.
4 * @author danvk@google.com (Dan Vanderkam)
6 describe("per-series", function() {
8 beforeEach(function() {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 afterEach(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('testNewStyleSeries', function() {
65 var graph
= document
.getElementById("graph");
66 var data
= "X,Y,Z\n1,0,0\n";
67 var g
= new Dygraph(graph
, data
, opts
);
69 assert
.equal(5, g
.getOption("pointSize"));
70 assert
.equal(4, g
.getOption("pointSize", "Y"));
71 assert
.equal(5, g
.getOption("pointSize", "Z"));
74 // TODO(konigsberg): move to multiple_axes.js
75 it('testAxisInNewSeries', function() {
84 var graph
= document
.getElementById("graph");
85 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
86 var g
= new Dygraph(graph
, data
, opts
);
88 assert
.deepEqual(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
89 assert
.deepEqual(["C", "D"], g
.attributes_
.seriesForAxis(1));
92 // TODO(konigsberg): move to multiple_axes.js
93 it('testAxisInNewSeries_withAxes', function() {
102 y
: { pointSize
: 7 },
103 y2
: { pointSize
: 6 }
106 var graph
= document
.getElementById("graph");
107 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
108 var g
= new Dygraph(graph
, data
, opts
);
110 assert
.deepEqual(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
111 assert
.deepEqual(["C", "D"], g
.attributes_
.seriesForAxis(1));
113 assert
.equal(1.5, g
.getOption("pointSize"));
114 assert
.equal(7, g
.getOption("pointSize", "A"));
115 assert
.equal(7, g
.getOption("pointSize", "B"));
116 assert
.equal(6, g
.getOption("pointSize", "C"));
117 assert
.equal(6, g
.getOption("pointSize", "D"));
118 assert
.equal(7, g
.getOption("pointSize", "E"));
121 // TODO(konigsberg): move to multiple_axes.js
122 it('testOldAxisSpecInNewSeriesThrows', function() {
128 var graph
= document
.getElementById("graph");
129 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
132 new Dygraph(graph
, data
, opts
);
137 assert
.isTrue(threw
);
140 it('testColorOption', function() {
141 var graph
= document
.getElementById("graph");
142 var data
= "X,A,B,C\n0,1,2,3\n";
143 var g
= new Dygraph(graph
, data
, {});
144 assert
.deepEqual(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g
.getColors());
145 g
.updateOptions({series
: { B
: { color
: 'purple' }}});
146 assert
.deepEqual(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g
.getColors());