From: Dan Vanderkam Date: Sun, 31 Jan 2010 05:10:28 +0000 (-0800) Subject: fix a bug involving calculation of span w/r/t/ includeZero X-Git-Tag: v1.0.0~743 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=d053ab5a1f2a48d598857724f7d571fd6df36e20;p=dygraphs.git fix a bug involving calculation of span w/r/t/ includeZero --- 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:

+
+ + + +