From: Robert Konigsberg Date: Fri, 4 Feb 2011 22:28:59 +0000 (-0500) Subject: Turns out that I had to also check for infinity, which happens when X-Git-Tag: v1.0.0~584^2~2^2~2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c742293ba320687849b9e695ef1ac9f205e6bf23;p=dygraphs.git Turns out that I had to also check for infinity, which happens when minYval is 0. Fixed that, plus, only set those values when it's log scale. Also fancied up the console message. --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 9b70f81..8133d86 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -89,11 +89,14 @@ DygraphLayout.prototype._evaluateLimits = function() { axis.yrange = axis.maxyval - axis.minyval; axis.yscale = (axis.yrange != 0 ? 1.0 / axis.yrange : 1.0); - axis.ylogrange = Dygraph.log10(axis.maxyval) - Dygraph.log10(axis.minyval); - axis.ylogscale = (axis.ylogrange != 0 ? 1.0 / axis.ylogrange : 1.0); - if (axis.g.attr_("logscale") && isNaN(axis.ylogrange)) { - axis.g.error('axis ' + i + ' can\'t be displayed in log scale for range [' + - axis.minyval + ' - ' + axis.maxyval + ']'); + if (axis.g.attr_("logscale")) { + axis.ylogrange = Dygraph.log10(axis.maxyval) - Dygraph.log10(axis.minyval); + axis.ylogscale = (axis.ylogrange != 0 ? 1.0 / axis.ylogrange : 1.0); + if (!isFinite(axis.ylogrange) || isNaN(axis.ylogrange)) { + axis.g.error('axis ' + i + ' of graph at ' + axis.g + + ' can\'t be displayed in log scale for range [' + + axis.minyval + ' - ' + axis.maxyval + ']'); + } } } };