2 * @fileoverview Tests for per-series options.
4 * @author danvk@google.com (Dan Vanderkam)
6 var perSeriesTestCase
= TestCase("per-series");
8 perSeriesTestCase
.prototype.setUp
= function() {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 perSeriesTestCase
.prototype.tearDown
= function() {
15 perSeriesTestCase
.prototype.testPerSeriesFill
= function() {
23 Y
: { fillGraph
: true },
24 colors
: [ '#FF0000', '#0000FF' ],
27 var data
= "X,Y,Z\n" +
38 var graph
= document
.getElementById("graph");
39 g
= new Dygraph(graph
, data
, opts
);
41 var sampler
= new PixelSampler(g
);
43 // Inside of the "Z" bump -- no fill.
44 assertEquals([0,0,0,0], sampler
.colorAtCoordinate(2.5, 0.5));
46 // Inside of the "Y" bump -- filled in.
47 assertEquals([255,0,0,38], sampler
.colorAtCoordinate(6.5, 0.5));
50 perSeriesTestCase
.prototype.testOldStyleSeries
= function() {
55 var graph
= document
.getElementById("graph");
56 var data
= "X,Y,Z\n1,0,0\n";
57 g
= new Dygraph(graph
, data
, opts
);
59 assertEquals(5, g
.getOption("pointSize"));
60 assertEquals(4, g
.getOption("pointSize", "Y"));
61 assertEquals(5, g
.getOption("pointSize", "Z"));
64 perSeriesTestCase
.prototype.testNewStyleSeries
= function() {
71 var graph
= document
.getElementById("graph");
72 var data
= "X,Y,Z\n1,0,0\n";
73 g
= new Dygraph(graph
, data
, opts
);
75 assertEquals(5, g
.getOption("pointSize"));
76 assertEquals(4, g
.getOption("pointSize", "Y"));
77 assertEquals(5, g
.getOption("pointSize", "Z"));
80 perSeriesTestCase
.prototype.testNewStyleSeriesTrumpsOldStyle
= function() {
83 Z
: { pointSize
: 6 },
88 var graph
= document
.getElementById("graph");
89 var data
= "X,Y,Z\n1,0,0\n";
90 g
= new Dygraph(graph
, data
, opts
);
92 assertEquals(5, g
.getOption("pointSize"));
93 assertEquals(4, g
.getOption("pointSize", "Y"));
94 assertEquals(5, g
.getOption("pointSize", "Z"));
96 // Erase the series object, and Z will become visible again.
97 g
.updateOptions({ series
: undefined
});
98 assertEquals(5, g
.getOption("pointSize"));
99 assertEquals(6, g
.getOption("pointSize", "Z"));
100 assertEquals(5, g
.getOption("pointSize", "Y"));
103 // TODO(konigsberg): move to multiple_axes.js
104 perSeriesTestCase
.prototype.testAxisInNewSeries
= function() {
113 var graph
= document
.getElementById("graph");
114 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
115 g
= new Dygraph(graph
, data
, opts
);
117 assertEquals(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
118 assertEquals(["C", "D"], g
.attributes_
.seriesForAxis(1));
121 // TODO(konigsberg): move to multiple_axes.js
122 perSeriesTestCase
.prototype.testAxisInNewSeries_withAxes
= function() {
131 y
: { pointSize
: 7 },
132 y2
: { pointSize
: 6 }
135 var graph
= document
.getElementById("graph");
136 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
137 g
= new Dygraph(graph
, data
, opts
);
139 assertEquals(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
140 assertEquals(["C", "D"], g
.attributes_
.seriesForAxis(1));
142 assertEquals(1.5, g
.getOption("pointSize"));
143 assertEquals(7, g
.getOption("pointSize", "A"));
144 assertEquals(7, g
.getOption("pointSize", "B"));
145 assertEquals(6, g
.getOption("pointSize", "C"));
146 assertEquals(6, g
.getOption("pointSize", "D"));
147 assertEquals(7, g
.getOption("pointSize", "E"));
150 // TODO(konigsberg): move to multiple_axes.js
151 perSeriesTestCase
.prototype.testOldAxisSpecInNewSeriesThrows
= function() {
157 var graph
= document
.getElementById("graph");
158 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
160 new Dygraph(graph
, data
, opts
);
163 "Using objects for axis specification is not supported inside the 'series' option.",