X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-canvas.js;h=de8d4fe573142a7f4833df64c6b980a38920a6ab;hb=8337da0a01d325f50c5b5f12d6d1dcedb42ed7c2;hp=f19e7a3d53394b59a47ec83511adaeb9d3c8c784;hpb=b843b52c15b95e0f97a172e67da0a3b865d1d5ee;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index f19e7a3..de8d4fe 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -691,13 +691,14 @@ DygraphCanvasRenderer.makeNextPointStep_ = function( } }; -var _isNullOrNaN = function(x) { +DygraphCanvasRenderer.isNullOrNaN_ = function(x) { return (x === null || isNaN(x)); }; DygraphCanvasRenderer.prototype._drawStyledLine = function( ctx, i, setName, color, strokeWidth, strokePattern, drawPoints, drawPointCallback, pointSize) { + // TODO(konigsberg): Compute attributes outside this method call. var stepPlot = this.attr_("stepPlot"); var firstIndexInSet = this.layout.setPointsOffsets[i]; var setLength = this.layout.setPointsLengths[i]; @@ -730,7 +731,7 @@ DygraphCanvasRenderer.prototype._drawNonTrivialLine = function( point = points[firstIndexInSet + j]; nextY = (next(j) < setLength) ? points[firstIndexInSet + next(j)].canvasy : null; - if (_isNullOrNaN(point.canvasy)) { + if (DygraphCanvasRenderer.isNullOrNaN_(point.canvasy)) { if (stepPlot && prevX !== null) { // Draw a horizontal line to the start of the missing data ctx.beginPath(); @@ -744,12 +745,12 @@ DygraphCanvasRenderer.prototype._drawNonTrivialLine = function( } else { // A point is "isolated" if it is non-null but both the previous // and next points are null. - var isIsolated = (!prevX && _isNullOrNaN(nextY)); + var isIsolated = (!prevX && DygraphCanvasRenderer.isNullOrNaN_(nextY)); if (drawGapPoints) { // Also consider a point to be is "isolated" if it's adjacent to a // null point, excluding the graph edges. if ((j > 0 && !prevX) || - (next(j) < setLength && _isNullOrNaN(nextY))) { + (next(j) < setLength && DygraphCanvasRenderer.isNullOrNaN_(nextY))) { isIsolated = true; } } @@ -806,15 +807,15 @@ DygraphCanvasRenderer.prototype._drawTrivialLine = function( for (var j = firstIndexInSet; j < firstIndexInSet + setLength; ++j) { var point = points[j]; nextY = (j + 1 < firstIndexInSet + setLength) ? points[j + 1].canvasy : null; - if (_isNullOrNaN(point.canvasy)) { + if (DygraphCanvasRenderer.isNullOrNaN_(point.canvasy)) { prevX = prevY = null; } else { - var isIsolated = (!prevX && _isNullOrNaN(nextY)); + var isIsolated = (!prevX && DygraphCanvasRenderer.isNullOrNaN_(nextY)); if (drawGapPoints) { // Also consider a point to be is "isolated" if it's adjacent to a // null point, excluding the graph edges. if ((j > firstIndexInSet && !prevX) || - ((j + 1 < firstIndexInSet + setLength) && _isNullOrNaN(nextY))) { + ((j + 1 < firstIndexInSet + setLength) && DygraphCanvasRenderer.isNullOrNaN_(nextY))) { isIsolated = true; } } @@ -850,6 +851,8 @@ DygraphCanvasRenderer.prototype._drawLine = function(ctx, i) { var borderWidth = this.dygraph_.attr_("strokeBorderWidth", setName); var drawPointCallback = this.dygraph_.attr_("drawPointCallback", setName) || Dygraph.Circles.DEFAULT; + + // TODO(konigsberg): Turn this into one call, and then consider inlining drawStyledLine. if (borderWidth && strokeWidth) { this._drawStyledLine(ctx, i, setName, this.dygraph_.attr_("strokeBorderColor", setName),