Merge pull request #673 from danvk/track-code-size
[dygraphs.git] / auto_tests / tests / fill_step_plot.js
1 /**
2 * @fileoverview Test if you give null values to dygraph with stepPlot
3 * and fillGraph options enabled
4 *
5 * @author benoitboivin.pro@gmail.com (Benoit Boivin)
6 */
7 describe("fill-step-plot", function() {
8
9 beforeEach(function() {
10 document.body.innerHTML = "<div id='graph'></div>";
11 });
12
13 var origFunc = Dygraph.getContext;
14
15 beforeEach(function() {
16 document.body.innerHTML = "<div id='graph'></div>";
17 Dygraph.getContext = function(canvas) {
18 return new Proxy(origFunc(canvas));
19 };
20 });
21
22 afterEach(function() {
23 Dygraph.getContext = origFunc;
24 });
25
26
27 it('testFillStepPlotNullValues', function() {
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 var 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
57 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, {});
58 });
59
60 });