From 6e6a2b0a85d2d34deb4fcecc2b8a32f6eb91a964 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Thu, 27 Jan 2011 17:56:20 -0500 Subject: [PATCH] Log scale graphs no longer show points with values less than zero. --- dygraph.js | 18 +++++++++++++++--- tests/logscale-zero.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 tests/logscale-zero.html diff --git a/dygraph.js b/dygraph.js index ccc79b7..0390a6f 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2136,12 +2136,24 @@ Dygraph.prototype.drawGraph_ = function() { var seriesName = this.attr_("labels")[i]; var connectSeparatedPoints = this.attr_('connectSeparatedPoints', i); + var logScale = this.attr_('logscale', i); var series = []; for (var j = 0; j < data.length; j++) { - if (data[j][i] != null || !connectSeparatedPoints) { - var date = data[j][0]; - series.push([date, data[j][i]]); + var date = data[j][0]; + var point = data[j][i]; + if (logScale) { + // On the log scale, points less than zero do not exist. + // This will create a gap in the chart. Note that this ignores + // connectSeparatedPoints. + if (point < 0) { + point = null; + } + series.push([date, point]); + } else { + if (point != null || !connectSeparatedPoints) { + series.push([date, point]); + } } } diff --git a/tests/logscale-zero.html b/tests/logscale-zero.html new file mode 100644 index 0000000..4eb83b3 --- /dev/null +++ b/tests/logscale-zero.html @@ -0,0 +1,45 @@ + + + log scale + + + + + + + + +

Log scale demo - work in progress

+
+ + + + + + + -- 2.7.4