From: Dan Vanderkam Date: Thu, 16 Aug 2012 19:45:52 +0000 (-0400) Subject: Fix issue 201:zero-series test broken X-Git-Tag: v1.0.0~192 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=44477387f9e610d6d792bd06d0cd85d32d694752;p=dygraphs.git Fix issue 201:zero-series test broken --- diff --git a/auto_tests/tests/custom_bars.js b/auto_tests/tests/custom_bars.js index e55b1c8..1e1b0c9 100644 --- a/auto_tests/tests/custom_bars.js +++ b/auto_tests/tests/custom_bars.js @@ -57,3 +57,21 @@ CustomBarsTestCase.prototype.testCustomBarsNoHang = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); }; + +// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=201 +CustomBarsTestCase.prototype.testCustomBarsZero = function() { + var opts = { + customBars: true + }; + var data = "X,Y1,Y2\n" + +"1,1;2;3,0;0;0\n" + +"2,2;3;4,0;0;0\n" + +"3,1;3;5,0;0;0\n"; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, opts); + + var range = g.yAxisRange(); + assertTrue('y-axis must include 0', range[0] <= 0); + assertTrue('y-axis must include 5', range[1] >= 5); +}; diff --git a/dygraph.js b/dygraph.js index c1764a1..471e4ee 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2106,7 +2106,7 @@ Dygraph.prototype.extremeValues_ = function(series) { // With custom bars, maxY is the max of the high values. for (j = 0; j < series.length; j++) { y = series[j][1][0]; - if (!y) continue; + if (y === null || isNaN(y)) continue; var low = y - series[j][1][1]; var high = y + series[j][1][2]; if (low > y) low = y; // this can happen with custom bars, @@ -2355,6 +2355,7 @@ Dygraph.prototype.drawGraph_ = function() { } this.computeYAxisRanges_(extremes); + console.log(extremes); this.layout_.setYAxes(this.axes_); this.addXTicks_();