From b7ec6c55209b94bde3ce07d783bfd885a57ad761 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 27 Sep 2013 08:35:38 +0100 Subject: [PATCH] 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. --- dygraph-canvas.js | 3 +++ dygraph-layout.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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); } -- 2.7.4