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() {
16 perSeriesTestCase
.prototype.testPerSeriesFill
= function() {
24 Y
: { fillGraph
: true },
25 colors
: [ '#FF0000', '#0000FF' ],
28 var data
= "X,Y,Z\n" +
39 var graph
= document
.getElementById("graph");
40 g
= new Dygraph(graph
, data
, opts
);
42 var sampler
= new PixelSampler(g
);
44 // Inside of the "Z" bump -- no fill.
45 assertEquals([0,0,0,0], sampler
.colorAtCoordinate(2.5, 0.5));
47 // Inside of the "Y" bump -- filled in.
48 assertEquals([255,0,0,38], sampler
.colorAtCoordinate(6.5, 0.5));
51 perSeriesTestCase
.prototype.testOldStyleSeries
= function() {
56 var graph
= document
.getElementById("graph");
57 var data
= "X,Y,Z\n1,0,0\n";
58 g
= new Dygraph(graph
, data
, opts
);
60 assertEquals(5, g
.getOption("pointSize"));
61 assertEquals(4, g
.getOption("pointSize", "Y"));
62 assertEquals(5, g
.getOption("pointSize", "Z"));
65 perSeriesTestCase
.prototype.testNewStyleSeries
= function() {
72 var graph
= document
.getElementById("graph");
73 var data
= "X,Y,Z\n1,0,0\n";
74 g
= new Dygraph(graph
, data
, opts
);
76 assertEquals(5, g
.getOption("pointSize"));
77 assertEquals(4, g
.getOption("pointSize", "Y"));
78 assertEquals(5, g
.getOption("pointSize", "Z"));
81 perSeriesTestCase
.prototype.testNewStyleSeriesTrumpsOldStyle
= function() {
84 Z
: { pointSize
: 6 },
89 var graph
= document
.getElementById("graph");
90 var data
= "X,Y,Z\n1,0,0\n";
91 g
= new Dygraph(graph
, data
, opts
);
93 assertEquals(5, g
.getOption("pointSize"));
94 assertEquals(4, g
.getOption("pointSize", "Y"));
95 assertEquals(5, g
.getOption("pointSize", "Z"));
97 // Erase the series object, and Z will become visible again.
98 g
.updateOptions({ series
: undefined
});
99 assertEquals(5, g
.getOption("pointSize"));
100 assertEquals(6, g
.getOption("pointSize", "Z"));
101 assertEquals(5, g
.getOption("pointSize", "Y"));