Add tests for new series option.
[dygraphs.git] / auto_tests / tests / per_series.js
1 /**
2 * @fileoverview Tests for per-series options.
3 *
4 * @author danvk@google.com (Dan Vanderkam)
5 */
6 var Tests for per-series options.
7
8 perSeriesTestCase.prototype.setUp = function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10 };
11
12 perSeriesTestCase.prototype.tearDown = function() {
13 };
14
15
16 perSeriesTestCase.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
51 perSeriesTestCase.prototype.testOldStyleSeries = function() {
52 var opts = {
53 pointSize : 5
54 Y: { pointSize : 4 },
55 };
56 var data = "X,Y,Z\n1,0,0\n";
57 g = new Dygraph("Graph", data, opts);
58
59 assertEquals(5, g.getOption("pointSize"));
60 assertEquals(4, g.getOption("pointSize", "Y"));
61 assertEquals(5, g.getOption("pointSize", "Z"));
62 };
63