From: Paul Holden Date: Fri, 27 Sep 2013 07:35:38 +0000 (+0100) Subject: Fix flaky testCustomBarsWithNegativeValuesInLogScale. DygraphLayout._calcYNormal... X-Git-Tag: v1.1.0~84 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=b7ec6c55209b94bde3ce07d783bfd885a57ad761;p=dygraphs.git Fix flaky testCustomBarsWithNegativeValuesInLogScale. DygraphLayout._calcYNormal(axis, NaN, logscale) initially returns NaN, but after it gets jitted it starts returning Infinity. Some of the downstream code doesn't handle this eventuality. --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index cba4f44..47d3e26 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -334,6 +334,9 @@ DygraphCanvasRenderer._drawSeries = function(e, point = arr[i]; } + // FIXME: The 'canvasy != canvasy' test here catches NaN values but the test + // doesn't catch Infinity values. Could change this to + // !isFinite(point.canvasy), but I assume it avoids isNaN for performance? if (point.canvasy === null || point.canvasy != point.canvasy) { if (stepPlot && prevCanvasX !== null) { // Draw a horizontal line to the start of the missing data diff --git a/dygraph-layout.js b/dygraph-layout.js index 56fdc3b..c1c2bc4 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -213,7 +213,8 @@ DygraphLayout.prototype._evaluateLimits = function() { DygraphLayout._calcYNormal = function(axis, value, logscale) { if (logscale) { - return 1.0 - ((Dygraph.log10(value) - Dygraph.log10(axis.minyval)) * axis.ylogscale); + var x = 1.0 - ((Dygraph.log10(value) - Dygraph.log10(axis.minyval)) * axis.ylogscale); + return isFinite(x) ? x : NaN; } else { return 1.0 - ((value - axis.minyval) * axis.yscale); }