From d053ab5a1f2a48d598857724f7d571fd6df36e20 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 30 Jan 2010 21:10:28 -0800 Subject: [PATCH] fix a bug involving calculation of span w/r/t/ includeZero --- dygraph.js | 5 +++++ tests/small-range-zero.html | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/small-range-zero.html diff --git a/dygraph.js b/dygraph.js index ea25980..1df7cc1 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1290,6 +1290,11 @@ Dygraph.prototype.drawGraph_ = function(data) { if (this.valueRange_ != null) { this.addYTicks_(this.valueRange_[0], this.valueRange_[1]); } else { + // This affects the calculation of span, below. + if (this.attr_("includeZero") && minY > 0) { + minY = 0; + } + // Add some padding and round up to an integer to be human-friendly. var span = maxY - minY; // special case: if we have no sense of scale, use +/-10% of the sole value. diff --git a/tests/small-range-zero.html b/tests/small-range-zero.html new file mode 100644 index 0000000..3226625 --- /dev/null +++ b/tests/small-range-zero.html @@ -0,0 +1,32 @@ + + + no range + + + + + + +

There should be an appropriate amount of padding at the top of the chart:

+
+ + + + -- 2.7.4