2 * @fileoverview Tests for per-axis options.
4 * @author konigsberg@google.com (Robert Konigsberg)
6 var perAxisTestCase
= TestCase("per-axis");
8 perAxisTestCase
._origGetContext
= Dygraph
.getContext
;
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
));
16 this.xAxisLineColor
= "#00ffff";
17 this.yAxisLineColor
= "#ffff00";
24 gridLineColor
: this.xAxisLineColor
29 gridLineColor
: this.yAxisLineColor
32 colors
: [ '#ff0000', '#0000ff' ]
35 var data
= "X,Y,Z\n" +
39 this.graph
= document
.getElementById('graph');
40 this.g
= new Dygraph(this.graph
, data
, opts
);
43 perAxisTestCase
.prototype.tearDown
= function() {
44 Dygraph
.getContext
= perAxisTestCase
._origGetContext
;
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);
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);
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);
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);