Closurize dygraph-options.js. Not done.
[dygraphs.git] / auto_tests / tests / multi_csv.js
1 /**
2 * @fileoverview Test cases for how axis labels are chosen and formatted.
3 *
4 * @author dan@dygraphs.com (Dan Vanderkam)
5 */
6 var MultiCsvTestCase = TestCase("multi-csv");
7
8 MultiCsvTestCase.prototype.setUp = function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10 };
11
12 MultiCsvTestCase.prototype.tearDown = function() {
13 };
14
15 function getXLabels() {
16 var x_labels = document.getElementsByClassName("dygraph-axis-label-x");
17 var ary = [];
18 for (var i = 0; i < x_labels.length; i++) {
19 ary.push(x_labels[i].innerHTML);
20 }
21 return ary;
22 }
23
24 MultiCsvTestCase.prototype.testOneCSV = function() {
25 var opts = {
26 width: 480,
27 height: 320
28 };
29 var data = "X,Y\n" +
30 "0,-1\n" +
31 "1,0\n" +
32 "2,1\n" +
33 "3,0\n"
34 ;
35
36 var graph = document.getElementById("graph");
37 var g = new Dygraph(graph, data, opts);
38
39 assertEquals(['0','0.5','1','1.5','2','2.5'], getXLabels());
40 };
41
42 MultiCsvTestCase.prototype.testTwoCSV = function() {
43 var opts = {
44 width: 480,
45 height: 320
46 };
47 var data = "X,Y\n" +
48 "0,-1\n" +
49 "1,0\n" +
50 "2,1\n" +
51 "3,0\n"
52 ;
53
54 var graph = document.getElementById("graph");
55 var g = new Dygraph(graph, data, opts);
56
57 assertEquals(['0','0.5','1','1.5','2','2.5'], getXLabels());
58
59 g.updateOptions({file: data});
60
61 assertEquals(['0','0.5','1','1.5','2','2.5'], getXLabels());
62 };