};
/**
- *
* @private
*/
DygraphCanvasRenderer.prototype._drawStyledLine = 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_;
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);
}
// 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];
continue;
}
- // TODO(danvk): here
if (stepPlot) {
newYs = [ point.y_bottom, point.y_top ];
prevY = point.y;