From: Robert Konigsberg Date: Fri, 4 Feb 2011 20:38:01 +0000 (-0500) Subject: Add error when computing axis scales that just won't display because of an invalid... X-Git-Tag: v1.0.0~587^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=d03e78ed03fbe85b86c67bbd0240248a80621e8b;p=dygraphs.git Add error when computing axis scales that just won't display because of an invalid range. --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index b90695b..9b70f81 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -91,6 +91,10 @@ DygraphLayout.prototype._evaluateLimits = function() { 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 + ']'); + } } }; @@ -105,7 +109,7 @@ DygraphLayout.prototype._evaluateLineCharts = function() { for (var j = 0; j < dataset.length; j++) { var item = dataset[j]; - + var yval; if (axis.logscale) { yval = 1.0 - ((Dygraph.log10(parseFloat(item[1])) - Dygraph.log10(axis.minyval)) * axis.ylogscale); // really should just be yscale. diff --git a/tests/logscale.html b/tests/logscale.html index 1d17bfa..be26ea1 100644 --- a/tests/logscale.html +++ b/tests/logscale.html @@ -51,12 +51,12 @@ }; var g0 = new Dygraph(document.getElementById("div_g0"), - data0, { logscale : true }); - var g1 = new Dygraph(document.getElementById("div_g1"), - data1, { logscale : true }); + data0, { logscale : true, valueRange: [-1,100] }); + // var g1 = new Dygraph(document.getElementById("div_g1"), + //data1, { logscale : true }); function setLogScale(val) { g0.updateOptions({ logscale: val }); - g1.updateOptions({ logscale: val }); + // g1.updateOptions({ logscale: val }); document.getElementById("linear").disabled = !val; document.getElementById("log").disabled = val; }