Commit | Line | Data |
---|---|---|
7f6a7190 RK |
1 | /** |
2 | * @fileoverview Tests for per-axis options. | |
3 | * | |
4 | * @author konigsberg@google.com (Robert Konigsberg) | |
5 | */ | |
e8c70e4e DV |
6 | |
7 | import Dygraph from '../../src/dygraph'; | |
8 | import * as utils from '../../src/dygraph-utils'; | |
9 | ||
10 | import Util from './Util'; | |
11 | import CanvasAssertions from './CanvasAssertions'; | |
12 | import Proxy from './Proxy'; | |
13 | ||
89fdcedb | 14 | describe("per-axis", function() { |
7f6a7190 | 15 | |
e8c70e4e DV |
16 | cleanupAfterEach(); |
17 | useProxyCanvas(utils, Proxy); | |
319d0361 DV |
18 | |
19 | var xAxisLineColor = "#00ffff"; | |
20 | var yAxisLineColor = "#ffff00"; | |
21 | ||
22 | var g, graph; | |
7f6a7190 | 23 | |
89fdcedb | 24 | beforeEach(function() { |
7f6a7190 RK |
25 | var opts = { |
26 | axes : { | |
27 | x : { | |
28 | drawAxis : false, | |
29 | drawGrid : false, | |
319d0361 | 30 | gridLineColor : xAxisLineColor |
7f6a7190 RK |
31 | }, |
32 | y : { | |
33 | drawAxis : false, | |
34 | drawGrid : false, | |
319d0361 | 35 | gridLineColor : yAxisLineColor |
7f6a7190 RK |
36 | } |
37 | }, | |
38 | colors: [ '#ff0000', '#0000ff' ] | |
39 | }; | |
40 | ||
41 | var data = "X,Y,Z\n" + | |
42 | "1,1,0\n" + | |
43 | "8,0,1\n" | |
44 | ; | |
319d0361 DV |
45 | graph = document.getElementById('graph'); |
46 | g = new Dygraph(graph, data, opts); | |
89fdcedb | 47 | }); |
7f6a7190 | 48 | |
89fdcedb | 49 | it('testDrawXAxis', function() { |
319d0361 | 50 | g.updateOptions({ axes : { x : { drawAxis: true }} }); |
89fdcedb DV |
51 | assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length > 0); |
52 | assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length == 0); | |
53 | }); | |
7f6a7190 | 54 | |
89fdcedb | 55 | it('testDrawYAxis', function() { |
319d0361 | 56 | g.updateOptions({ axes : { y : { drawAxis: true }} }); |
89fdcedb DV |
57 | assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length ==0); |
58 | assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length > 0); | |
59 | }); | |
7f6a7190 | 60 | |
89fdcedb | 61 | it('testDrawXGrid', function() { |
319d0361 DV |
62 | g.updateOptions({ axes : { x : { drawGrid : true }}}); |
63 | var htx = g.hidden_ctx_; | |
89fdcedb DV |
64 | assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) > 0); |
65 | assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) == 0); | |
66 | }); | |
7f6a7190 | 67 | |
89fdcedb | 68 | it('testDrawYGrid', function() { |
319d0361 DV |
69 | g.updateOptions({ axes : { y : { drawGrid : true }}}); |
70 | var htx = g.hidden_ctx_; | |
89fdcedb DV |
71 | assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) == 0); |
72 | assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) > 0); | |
73 | }); | |
74 | ||
75 | }); |