Remove legacy options:
[dygraphs.git] / auto_tests / tests / per_axis.js
1 /**
2 * @fileoverview Tests for per-axis options.
3 *
4 * @author konigsberg@google.com (Robert Konigsberg)
5 */
6 var perAxisTestCase = TestCase("per-axis");
7
8 perAxisTestCase._origGetContext = Dygraph.getContext;
9
10 perAxisTestCase.prototype.setUp = function() {
11 document.body.innerHTML = "<div id='graph'></div>";
12 Dygraph.getContext = function(canvas) {
13 return new Proxy(perAxisTestCase._origGetContext(canvas));
14 }
15
16 this.xAxisLineColor = "#00ffff";
17 this.yAxisLineColor = "#ffff00";
18
19 var opts = {
20 axes : {
21 x : {
22 drawAxis : false,
23 drawGrid : false,
24 gridLineColor : this.xAxisLineColor
25 },
26 y : {
27 drawAxis : false,
28 drawGrid : false,
29 gridLineColor : this.yAxisLineColor
30 }
31 },
32 colors: [ '#ff0000', '#0000ff' ]
33 };
34
35 var data = "X,Y,Z\n" +
36 "1,1,0\n" +
37 "8,0,1\n"
38 ;
39 this.graph = document.getElementById('graph');
40 this.g = new Dygraph(this.graph, data, opts);
41 };
42
43 perAxisTestCase.prototype.tearDown = function() {
44 Dygraph.getContext = perAxisTestCase._origGetContext;
45 };
46
47 perAxisTestCase.prototype.testDrawXAxis = function() {
48 this.g.updateOptions({ axes : { x : { drawAxis: true }} });
49 assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length > 0);
50 assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length == 0);
51 }
52
53 perAxisTestCase.prototype.testDrawYAxis = function() {
54 this.g.updateOptions({ axes : { y : { drawAxis: true }} });
55 assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length ==0);
56 assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length > 0);
57 }
58
59 perAxisTestCase.prototype.testDrawXGrid = function() {
60 this.g.updateOptions({ axes : { x : { drawGrid : true }}});
61 var htx = this.g.hidden_ctx_;
62 assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) > 0);
63 assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) == 0);
64 }
65
66 perAxisTestCase.prototype.testDrawYGrid = function() {
67 this.g.updateOptions({ axes : { y : { drawGrid : true }}});
68 var htx = this.g.hidden_ctx_;
69 assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) == 0);
70 assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) > 0);
71 }