a3bdbad7a2d0d05012e0db3c1259585c189412a7
2 * @fileoverview Tests for per-axis options.
4 * @author konigsberg@google.com (Robert Konigsberg)
6 var perAxisTestCase
= TestCase("per-axis");
8 var _origGetContext
= Dygraph
.getContext
;
10 var xAxisLineColor
= "#00ffff";
11 var yAxisLineColor
= "#ffff00";
15 perAxisTestCase
.prototype.setUp
= function() {
16 document
.body
.innerHTML
= "<div id='graph'></div>";
17 Dygraph
.getContext
= function(canvas
) {
18 return new Proxy(_origGetContext(canvas
));
26 gridLineColor
: xAxisLineColor
31 gridLineColor
: yAxisLineColor
34 colors
: [ '#ff0000', '#0000ff' ]
37 var data
= "X,Y,Z\n" +
41 graph
= document
.getElementById('graph');
42 g
= new Dygraph(graph
, data
, opts
);
45 perAxisTestCase
.prototype.tearDown
= function() {
46 Dygraph
.getContext
= _origGetContext
;
49 perAxisTestCase
.prototype.testDrawXAxis
= function() {
50 g
.updateOptions({ axes
: { x
: { drawAxis
: true }} });
51 assertTrue(graph
.getElementsByClassName('dygraph-axis-label-x').length
> 0);
52 assertTrue(graph
.getElementsByClassName('dygraph-axis-label-y').length
== 0);
55 perAxisTestCase
.prototype.testDrawYAxis
= function() {
56 g
.updateOptions({ axes
: { y
: { drawAxis
: true }} });
57 assertTrue(graph
.getElementsByClassName('dygraph-axis-label-x').length
==0);
58 assertTrue(graph
.getElementsByClassName('dygraph-axis-label-y').length
> 0);
61 perAxisTestCase
.prototype.testDrawXGrid
= function() {
62 g
.updateOptions({ axes
: { x
: { drawGrid
: true }}});
63 var htx
= g
.hidden_ctx_
;
64 assertTrue(CanvasAssertions
.numLinesDrawn(htx
, xAxisLineColor
) > 0);
65 assertTrue(CanvasAssertions
.numLinesDrawn(htx
, yAxisLineColor
) == 0);
68 perAxisTestCase
.prototype.testDrawYGrid
= function() {
69 g
.updateOptions({ axes
: { y
: { drawGrid
: true }}});
70 var htx
= g
.hidden_ctx_
;
71 assertTrue(CanvasAssertions
.numLinesDrawn(htx
, xAxisLineColor
) == 0);
72 assertTrue(CanvasAssertions
.numLinesDrawn(htx
, yAxisLineColor
) > 0);