| | 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 | import Dygraph from '../../src/dygraph'; |
| | 8 | import * as utils from '../../src/dygraph-utils'; |
| | 9 | import CanvasAssertions from './CanvasAssertions'; |
| | 10 | import Proxy from './Proxy'; |
| | 11 | |
| | 12 | describe("fill-step-plot", function() { |
| | 13 | |
| | 14 | cleanupAfterEach(); |
| | 15 | |
| | 16 | var origFunc = utils.getContext; |
| | 17 | |
| | 18 | beforeEach(function() { |
| | 19 | utils.getContext = function(canvas) { |
| | 20 | return new Proxy(origFunc(canvas)); |
| | 21 | }; |
| | 22 | }); |
| | 23 | |
| | 24 | afterEach(function() { |
| | 25 | utils.getContext = origFunc; |
| | 26 | }); |
| | 27 | |
| | 28 | |
| | 29 | it('testFillStepPlotNullValues', function() { |
| | 30 | var opts = { |
| | 31 | labels: ["x","y"], |
| | 32 | width: 480, |
| | 33 | height: 320, |
| | 34 | fillGraph: true, |
| | 35 | stepPlot: true |
| | 36 | }; |
| | 37 | var data = [ |
| | 38 | [1,3], |
| | 39 | [2,0], |
| | 40 | [3,8], |
| | 41 | [4,null], |
| | 42 | [5,9], |
| | 43 | [6,8], |
| | 44 | [7,6], |
| | 45 | [8,3] |
| | 46 | ]; |
| | 47 | var graph = document.getElementById("graph"); |
| | 48 | var g = new Dygraph(graph, data, opts); |
| | 49 | |
| | 50 | var htx = g.hidden_ctx_; |
| | 51 | var x1 = data[3][0]; |
| | 52 | var y1 = data[2][1]; |
| | 53 | var x2 = data[3][0]; |
| | 54 | var y2 = 0; |
| | 55 | var xy1 = g.toDomCoords(x1, y1); |
| | 56 | var xy2 = g.toDomCoords(x2, y2); |
| | 57 | |
| | 58 | // Check if a line is drawn between the previous y and the bottom of the chart |
| | 59 | CanvasAssertions.assertLineDrawn(htx, xy1, xy2, {}); |
| | 60 | }); |
| | 61 | |
| | 62 | }); |