Commit | Line | Data |
---|---|---|
8c31c7db | 1 | /** |
a78b8bd0 | 2 | * @fileoverview Test if you give null values to dygraph with stepPlot |
8c31c7db BB |
3 | * and fillGraph options enabled |
4 | * | |
5 | * @author benoitboivin.pro@gmail.com (Benoit Boivin) | |
6 | */ | |
89fdcedb | 7 | describe("fill-step-plot", function() { |
8c31c7db | 8 | |
89fdcedb | 9 | beforeEach(function() { |
8c31c7db | 10 | document.body.innerHTML = "<div id='graph'></div>"; |
89fdcedb | 11 | }); |
8c31c7db | 12 | |
319d0361 | 13 | var origFunc = Dygraph.getContext; |
8c31c7db | 14 | |
89fdcedb | 15 | beforeEach(function() { |
8c31c7db BB |
16 | document.body.innerHTML = "<div id='graph'></div>"; |
17 | Dygraph.getContext = function(canvas) { | |
319d0361 | 18 | return new Proxy(origFunc(canvas)); |
8c31c7db | 19 | }; |
89fdcedb | 20 | }); |
8c31c7db | 21 | |
89fdcedb | 22 | afterEach(function() { |
319d0361 | 23 | Dygraph.getContext = origFunc; |
89fdcedb | 24 | }); |
8c31c7db BB |
25 | |
26 | ||
89fdcedb | 27 | it('testFillStepPlotNullValues', function() { |
8c31c7db BB |
28 | var opts = { |
29 | labels: ["x","y"], | |
30 | width: 480, | |
31 | height: 320, | |
32 | fillGraph: true, | |
33 | stepPlot: true | |
34 | }; | |
35 | var data = [ | |
36 | [1,3], | |
37 | [2,0], | |
38 | [3,8], | |
39 | [4,null], | |
40 | [5,9], | |
41 | [6,8], | |
42 | [7,6], | |
43 | [8,3] | |
44 | ]; | |
45 | var graph = document.getElementById("graph"); | |
46 | var g = new Dygraph(graph, data, opts); | |
47 | ||
89fdcedb | 48 | var htx = g.hidden_ctx_; |
8c31c7db BB |
49 | var x1 = data[3][0]; |
50 | var y1 = data[2][1]; | |
51 | var x2 = data[3][0]; | |
52 | var y2 = 0; | |
53 | var xy1 = g.toDomCoords(x1, y1); | |
54 | var xy2 = g.toDomCoords(x2, y2); | |
55 | ||
56 | // Check if a line is drawn between the previous y and the bottom of the chart | |
a78b8bd0 | 57 | CanvasAssertions.assertLineDrawn(htx, xy1, xy2, {}); |
89fdcedb DV |
58 | }); |
59 | ||
60 | }); |