X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph-canvas.js;h=979688d907ab50e7317c881ea27a794bdf85e33d;hb=16269f6e2b690bdeec989364ae7e80995846adc9;hp=70998bdc8359e9282ead69740ed7017ffb33ca50;hpb=43af96e75cba5447301daf3fa4347729d115fdc8;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 70998bd..979688d 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -85,9 +85,7 @@ DygraphLayout.prototype._evaluateLineCharts = function() { if (point.y >= 1.0) { point.y = 1.0; } - if ((point.x >= 0.0) && (point.x <= 1.0)) { - this.points.push(point); - } + this.points.push(point); } } }; @@ -189,6 +187,7 @@ DygraphCanvasRenderer = function(dygraph, element, layout, options) { "drawXGrid": true, "gridLineColor": "rgb(128,128,128)", "fillAlpha": 0.15, + "underlayCallback": null }; Dygraph.update(this.options, options); @@ -278,6 +277,11 @@ DygraphCanvasRenderer.isSupported = function(canvasName) { DygraphCanvasRenderer.prototype.render = function() { // Draw the new X/Y grid var ctx = this.element.getContext("2d"); + + if (this.options.underlayCallback) { + this.options.underlayCallback(ctx, this.area, this.layout); + } + if (this.options.drawYGrid) { var ticks = this.layout.yticks; ctx.save(); @@ -484,7 +488,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = this.options.strokeWidth; - var prevX = -1; + var prevX = NaN; var prevYs = [-1, -1]; var count = 0; var yscale = this.layout.yscale; @@ -499,7 +503,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { count++; if (point.name == setName) { if (!isOK(point.y)) { - prevX = -1; + prevX = NaN; continue; } // TODO(danvk): here @@ -507,7 +511,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { 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 (prevX >= 0) { + if (!isNaN(prevX)) { ctx.moveTo(prevX, prevYs[0]); ctx.lineTo(point.canvasx, newYs[0]); ctx.lineTo(point.canvasx, newYs[1]); @@ -533,7 +537,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = this.options.strokeWidth; - var prevX = -1; + var prevX = NaN; var prevYs = [-1, -1]; var count = 0; var yscale = this.layout.yscale; @@ -548,7 +552,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { count++; if (point.name == setName) { if (!isOK(point.y)) { - prevX = -1; + prevX = NaN; continue; } var pX = 1.0 + this.layout.minyval * this.layout.yscale; @@ -557,7 +561,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { var newYs = [ point.y, pX ]; newYs[0] = this.area.h * newYs[0] + this.area.y; newYs[1] = this.area.h * newYs[1] + this.area.y; - if (prevX >= 0) { + if (!isNaN(prevX)) { ctx.moveTo(prevX, prevYs[0]); ctx.lineTo(point.canvasx, newYs[0]); ctx.lineTo(point.canvasx, newYs[1]);