x axis log scale.
[dygraphs.git] / auto_tests / tests / dygraph-options-tests.js
1 /**
2 * @fileoverview Test cases for DygraphOptions.
3 */
4 var DygraphOptionsTestCase = TestCase("dygraph-options-tests");
5
6 DygraphOptionsTestCase.prototype.setUp = function() {
7 document.body.innerHTML = "<div id='graph'></div>";
8 };
9
10 DygraphOptionsTestCase.prototype.tearDown = function() {
11 };
12
13 /*
14 * Pathalogical test to ensure getSeriesNames works
15 */
16 DygraphOptionsTestCase.prototype.testGetSeriesNames = function() {
17 var opts = {
18 width: 480,
19 height: 320
20 };
21 var data = "X,Y,Y2,Y3\n" +
22 "0,-1,0,0";
23
24 // Kind of annoying that you need a DOM to test the object.
25 var graph = document.getElementById("graph");
26 var g = new Dygraph(graph, data, opts);
27
28 // We don't need to get at g's attributes_ object just
29 // to test DygraphOptions.
30 var o = new DygraphOptions(g);
31 assertEquals(["Y", "Y2", "Y3"], o.seriesNames());
32 };
33
34 /*
35 * Ensures that even if logscale is set globally, it doesn't impact the
36 * x axis.
37 */
38 DygraphOptionsTestCase.prototype.getLogscaleForX = function() {
39 var opts = {
40 width: 480,
41 height: 320
42 };
43 var data = "X,Y,Y2,Y3\n" +
44 "1,-1,2,3";
45
46 // Kind of annoying that you need a DOM to test the object.
47 var graph = document.getElementById("graph");
48 var g = new Dygraph(graph, data, opts);
49
50 assertFalse(g.getOptionForAxis('logscale', 'x'));
51 assertFalse(g.getOptionForAxis('logscale', 'y'));
52
53 g.updateOptions({ logscale : true });
54 assertFalse(g.getOptionForAxis('logscale', 'x'));
55 assertTrue(g.getOptionForAxis('logscale', 'y'));
56 };