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 | */ | |
7 | var fillStepPlotTestCase = TestCase("fill-step-plot"); | |
8 | ||
9 | fillStepPlotTestCase.prototype.setUp = function() { | |
10 | document.body.innerHTML = "<div id='graph'></div>"; | |
11 | }; | |
12 | ||
13 | fillStepPlotTestCase.origFunc = Dygraph.getContext; | |
14 | ||
15 | fillStepPlotTestCase.prototype.setUp = function() { | |
16 | document.body.innerHTML = "<div id='graph'></div>"; | |
17 | Dygraph.getContext = function(canvas) { | |
18 | return new Proxy(fillStepPlotTestCase.origFunc(canvas)); | |
19 | }; | |
20 | }; | |
21 | ||
22 | fillStepPlotTestCase.prototype.tearDown = function() { | |
23 | Dygraph.getContext = fillStepPlotTestCase.origFunc; | |
24 | }; | |
25 | ||
26 | ||
27 | fillStepPlotTestCase.prototype.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 | ||
48 | htx = g.hidden_ctx_; | |
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, {}); |
8c31c7db | 58 | }; |