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 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(5, g
.getOption("pointSize"));
118 assertEquals(4, g
.getOption("pointSize", "Y"));
119 assertEquals(5, g
.getOption("pointSize", "Z"));
122 perSeriesTestCase
.prototype.testAxisInNewSeries_withAxes
= function() {
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(5, g
.getOption("pointSize"));
140 assertEquals(4, g
.getOption("pointSize", "Y"));
141 assertEquals(5, g
.getOption("pointSize", "Z"));