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() {
24 Y
: { fillGraph
: true },
26 colors
: [ '#FF0000', '#0000FF' ],
29 var data
= "X,Y,Z\n" +
40 var graph
= document
.getElementById("graph");
41 g
= new Dygraph(graph
, data
, opts
);
43 var sampler
= new PixelSampler(g
);
45 // Inside of the "Z" bump -- no fill.
46 assertEquals([0,0,0,0], sampler
.colorAtCoordinate(2.5, 0.5));
48 // Inside of the "Y" bump -- filled in.
49 assertEquals([255,0,0,38], sampler
.colorAtCoordinate(6.5, 0.5));
52 perSeriesTestCase
.prototype.testNewStyleSeries
= function() {
59 var graph
= document
.getElementById("graph");
60 var data
= "X,Y,Z\n1,0,0\n";
61 g
= new Dygraph(graph
, data
, opts
);
63 assertEquals(5, g
.getOption("pointSize"));
64 assertEquals(4, g
.getOption("pointSize", "Y"));
65 assertEquals(5, g
.getOption("pointSize", "Z"));
68 // TODO(konigsberg): move to multiple_axes.js
69 perSeriesTestCase
.prototype.testAxisInNewSeries
= function() {
78 var graph
= document
.getElementById("graph");
79 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
80 g
= new Dygraph(graph
, data
, opts
);
82 assertEquals(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
83 assertEquals(["C", "D"], g
.attributes_
.seriesForAxis(1));
86 // TODO(konigsberg): move to multiple_axes.js
87 perSeriesTestCase
.prototype.testAxisInNewSeries_withAxes
= function() {
96 y
: { pointSize
: 7 },
97 y2
: { pointSize
: 6 }
100 var graph
= document
.getElementById("graph");
101 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
102 g
= new Dygraph(graph
, data
, opts
);
104 assertEquals(["A", "B", "E"], g
.attributes_
.seriesForAxis(0));
105 assertEquals(["C", "D"], g
.attributes_
.seriesForAxis(1));
107 assertEquals(1.5, g
.getOption("pointSize"));
108 assertEquals(7, g
.getOption("pointSize", "A"));
109 assertEquals(7, g
.getOption("pointSize", "B"));
110 assertEquals(6, g
.getOption("pointSize", "C"));
111 assertEquals(6, g
.getOption("pointSize", "D"));
112 assertEquals(7, g
.getOption("pointSize", "E"));
115 // TODO(konigsberg): move to multiple_axes.js
116 perSeriesTestCase
.prototype.testOldAxisSpecInNewSeriesThrows
= function() {
122 var graph
= document
.getElementById("graph");
123 var data
= "X,A,B,C,D,E\n0,1,2,3,4,5\n";
126 new Dygraph(graph
, data
, opts
);
134 perSeriesTestCase
.prototype.testColorOption
= function() {
135 var graph
= document
.getElementById("graph");
136 var data
= "X,A,B,C\n0,1,2,3\n";
137 var g
= new Dygraph(graph
, data
, {});
138 assertEquals(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g
.getColors());
139 g
.updateOptions({series
: { B
: { color
: 'purple' }}});
140 assertEquals(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g
.getColors());