X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph-canvas.js;h=d5c812e196398374fc196b2e1aa0323b9a860784;hb=5d13ef68a27544eff72ea3a2ef3aabdc4c4fd740;hp=09ce16b2ff7b85f14f0cdeb74077d3e1571e9056;hpb=afdc483f63032d8bba075b5a424ab48b32f9d332;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 09ce16b..d5c812e 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -513,26 +513,26 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { // TODO(danvk): here if (stepPlot) { var newYs = [ prevY - point.errorPlus * yscale, - prevY + point.errorMinus * yscale ]; + prevY + point.errorMinus * yscale ]; prevY = point.y; } else { var newYs = [ point.y - point.errorPlus * yscale, - point.y + point.errorMinus * yscale ]; + point.y + point.errorMinus * yscale ]; } newYs[0] = this.area.h * newYs[0] + this.area.y; newYs[1] = this.area.h * newYs[1] + this.area.y; if (!isNaN(prevX)) { if (stepPlot) { - ctx.moveTo(prevX, newYs[0]); + ctx.moveTo(prevX, newYs[0]); } else { - ctx.moveTo(prevX, prevYs[0]); + ctx.moveTo(prevX, prevYs[0]); } ctx.lineTo(point.canvasx, newYs[0]); ctx.lineTo(point.canvasx, newYs[1]); if (stepPlot) { - ctx.lineTo(prevX, newYs[1]); + ctx.lineTo(prevX, newYs[1]); } else { - ctx.lineTo(prevX, prevYs[1]); + ctx.lineTo(prevX, prevYs[1]); } ctx.closePath(); } @@ -585,9 +585,9 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { if (!isNaN(prevX)) { ctx.moveTo(prevX, prevYs[0]); if (stepPlot) { - ctx.lineTo(point.canvasx, prevYs[0]); + ctx.lineTo(point.canvasx, prevYs[0]); } else { - ctx.lineTo(point.canvasx, newYs[0]); + ctx.lineTo(point.canvasx, newYs[0]); } ctx.lineTo(point.canvasx, newYs[1]); ctx.lineTo(prevX, prevYs[1]); @@ -616,6 +616,15 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { var point = points[j]; if (point.name == setName) { if (!isOK(point.canvasy)) { + if (stepPlot && prevX != null) { + // Draw a horizontal line to the start of the missing data + ctx.beginPath(); + ctx.strokeStyle = color; + ctx.lineWidth = this.options.strokeWidth; + ctx.moveTo(prevX, prevY); + ctx.lineTo(point.canvasx, prevY); + ctx.stroke(); + } // this will make us move to the next point, not draw a line to it. prevX = prevY = null; } else { @@ -633,7 +642,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { ctx.lineWidth = this.options.strokeWidth; ctx.moveTo(prevX, prevY); if (stepPlot) { - ctx.lineTo(point.canvasx, prevY); + ctx.lineTo(point.canvasx, prevY); } prevX = point.canvasx; prevY = point.canvasy;