X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-canvas.js;h=450c8a9f396e9535a2849f1af8bf7147a3edd077;hb=13f8b0472ff8e7336bdf56f69ff838a1f3e76162;hp=a8b9807d92dfd5dde6a82cbcf6c76cb9cadb9fd2;hpb=c560c848f1334c9dadaf5ac7b70dec6f4bd45c00;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index a8b9807..450c8a9 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -243,7 +243,6 @@ DygraphCanvasRenderer._predicateThatSkipsEmptyPoints = }; /** - * * @private */ DygraphCanvasRenderer.prototype._drawStyledLine = function( @@ -306,6 +305,7 @@ DygraphCanvasRenderer.prototype._drawSeries = function( ctx.strokeStyle = color; ctx.lineWidth = strokeWidth; + // NOTE: we break the iterator's encapsulation here for about a 25% speedup. var arr = iter.array_; var limit = iter.end_; var predicate = iter.predicate_; @@ -354,6 +354,8 @@ DygraphCanvasRenderer.prototype._drawSeries = function( ctx.lineTo(point.canvasx, prevCanvasY); prevCanvasX = point.canvasx; } + + // TODO(danvk): this moveTo is rarely necessary ctx.moveTo(prevCanvasX, prevCanvasY); ctx.lineTo(point.canvasx, point.canvasy); } @@ -419,6 +421,12 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { // TODO(bhs): this loop is a hot-spot for high-point-count charts. These // transformations can be pushed into the canvas via linear transformation // matrices. + // NOTE(danvk): this is trickier than it sounds at first. The transformation + // needs to be done before the .moveTo() and .lineTo() calls, but must be + // undone before the .stroke() call to ensure that the stroke width is + // unaffected. An alternative is to reduce the stroke width in the + // transformed coordinate space, but you can't specify different values for + // each dimension (as you can with .scale()). The speedup here is ~12%. var points = this.layout.points; for (i = points.length; i--;) { var point = points[i]; @@ -495,7 +503,6 @@ DygraphCanvasRenderer.prototype.drawErrorBars_ = function(points) { continue; } - // TODO(danvk): here if (stepPlot) { newYs = [ point.y_bottom, point.y_top ]; prevY = point.y;