Fix options reference, so it includes 'Series' category.
[dygraphs.git] / auto_tests / tests / per_series.js
CommitLineData
e2d8db3a 1/**
30abcfb6 2 * @fileoverview Tests for per-series options.
e2d8db3a
DV
3 *
4 * @author danvk@google.com (Dan Vanderkam)
5 */
5bd8dcae 6var perSeriesTestCase = TestCase("per-series");
e2d8db3a
DV
7
8perSeriesTestCase.prototype.setUp = function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10};
11
12perSeriesTestCase.prototype.tearDown = function() {
13};
14
e2d8db3a
DV
15
16perSeriesTestCase.prototype.testPerSeriesFill = function() {
17 var opts = {
18 width: 480,
19 height: 320,
20 drawXGrid: false,
21 drawYGrid: false,
22 drawXAxis: false,
23 drawYAxis: false,
24 Y: { fillGraph: true },
25 colors: [ '#FF0000', '#0000FF' ],
26 fillAlpha: 0.15
27 };
28 var data = "X,Y,Z\n" +
29 "1,0,0\n" +
30 "2,0,1\n" +
31 "3,0,1\n" +
32 "4,0,0\n" +
33 "5,0,0\n" +
34 "6,1,0\n" +
35 "7,1,0\n" +
36 "8,0,0\n"
37 ;
38
39 var graph = document.getElementById("graph");
40 g = new Dygraph(graph, data, opts);
41
42 var sampler = new PixelSampler(g);
43
44 // Inside of the "Z" bump -- no fill.
45 assertEquals([0,0,0,0], sampler.colorAtCoordinate(2.5, 0.5));
46
47 // Inside of the "Y" bump -- filled in.
48 assertEquals([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5));
49};
50
30abcfb6
RK
51perSeriesTestCase.prototype.testOldStyleSeries = function() {
52 var opts = {
5bd8dcae 53 pointSize : 5,
30abcfb6
RK
54 Y: { pointSize : 4 },
55 };
0fe209e5
RK
56 var graph = document.getElementById("graph");
57 var data = "X,Y,Z\n1,0,0\n";
58 g = new Dygraph(graph, data, opts);
59
60 assertEquals(5, g.getOption("pointSize"));
61 assertEquals(4, g.getOption("pointSize", "Y"));
62 assertEquals(5, g.getOption("pointSize", "Z"));
63};
64
65perSeriesTestCase.prototype.testNewStyleSeries = function() {
66 var opts = {
67 pointSize : 5,
68 series : {
69 Y: { pointSize : 4 }
70 },
71 };
72 var graph = document.getElementById("graph");
73 var data = "X,Y,Z\n1,0,0\n";
74 g = new Dygraph(graph, data, opts);
75
76 assertEquals(5, g.getOption("pointSize"));
77 assertEquals(4, g.getOption("pointSize", "Y"));
78 assertEquals(5, g.getOption("pointSize", "Z"));
79};
80
81perSeriesTestCase.prototype.testNewStyleSeriesTrumpsOldStyle = function() {
82 var opts = {
83 pointSize : 5,
84 Z : { pointSize : 6 },
85 series : {
86 Y: { pointSize : 4 }
87 },
88 };
89 var graph = document.getElementById("graph");
30abcfb6 90 var data = "X,Y,Z\n1,0,0\n";
0fe209e5 91 g = new Dygraph(graph, data, opts);
30abcfb6
RK
92
93 assertEquals(5, g.getOption("pointSize"));
94 assertEquals(4, g.getOption("pointSize", "Y"));
95 assertEquals(5, g.getOption("pointSize", "Z"));
0fe209e5
RK
96
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"));
30abcfb6
RK
102};
103