Commit | Line | Data |
---|---|---|
d7beab6b DV |
1 | /** |
2 | * @fileoverview Test cases for how axis labels are chosen and formatted. | |
3 | * | |
4 | * @author dan@dygraphs.com (Dan Vanderkam) | |
5 | */ | |
89fdcedb | 6 | describe("multi-csv", function() { |
d7beab6b | 7 | |
89fdcedb | 8 | beforeEach(function() { |
d7beab6b | 9 | document.body.innerHTML = "<div id='graph'></div>"; |
89fdcedb | 10 | }); |
d7beab6b | 11 | |
89fdcedb DV |
12 | afterEach(function() { |
13 | }); | |
d7beab6b DV |
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 | ||
89fdcedb | 24 | it('testOneCSV', function() { |
d7beab6b DV |
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 | ||
89fdcedb DV |
39 | assert.deepEqual(['0', '1', '2'], getXLabels()); |
40 | }); | |
d7beab6b | 41 | |
89fdcedb | 42 | it('testTwoCSV', function() { |
d7beab6b DV |
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 | ||
89fdcedb | 57 | assert.deepEqual(['0', '1', '2'], getXLabels()); |
d7beab6b DV |
58 | |
59 | g.updateOptions({file: data}); | |
60 | ||
89fdcedb DV |
61 | assert.deepEqual(['0', '1', '2'], getXLabels()); |
62 | }); | |
63 | ||
64 | }); |