Commit | Line | Data |
---|---|---|
8c31c7db BB |
1 | /** |
2 | * @fileoverview Test if you put give null values to dygraph with stepPlot | |
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() { | |
28 | var attrs = {}; | |
29 | var opts = { | |
30 | labels: ["x","y"], | |
31 | width: 480, | |
32 | height: 320, | |
33 | fillGraph: true, | |
34 | stepPlot: true | |
35 | }; | |
36 | var data = [ | |
37 | [1,3], | |
38 | [2,0], | |
39 | [3,8], | |
40 | [4,null], | |
41 | [5,9], | |
42 | [6,8], | |
43 | [7,6], | |
44 | [8,3] | |
45 | ]; | |
46 | var graph = document.getElementById("graph"); | |
47 | var g = new Dygraph(graph, data, opts); | |
48 | ||
49 | htx = g.hidden_ctx_; | |
50 | var x1 = data[3][0]; | |
51 | var y1 = data[2][1]; | |
52 | var x2 = data[3][0]; | |
53 | var y2 = 0; | |
54 | var xy1 = g.toDomCoords(x1, y1); | |
55 | var xy2 = g.toDomCoords(x2, y2); | |
56 | ||
57 | // Check if a line is drawn between the previous y and the bottom of the chart | |
58 | CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs); | |
59 | }; |