From: manufitoussi Date: Fri, 25 Jan 2013 17:31:44 +0000 (+0100) Subject: Partial auto y range : adding support of null and undefined in addition to NaN X-Git-Tag: v1.0.0~105^2~7 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=30aae41c80030ffbcff46e6fad124fe250e72994;p=dygraphs.git Partial auto y range : adding support of null and undefined in addition to NaN --- diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index 96e5eb7..83a2505 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -78,6 +78,22 @@ RangeTestCase.prototype.testRangeSetOperations = function() { assertEquals([12, 18], g.xAxisRange()); assertEquals([10, 40], g.yAxisRange(0)); + g.updateOptions({ valueRange: [10, null] }); + assertEquals([12, 18], g.xAxisRange()); + assertEquals([10, 44.2], g.yAxisRange(0)); + + g.updateOptions({ valueRange: [10, 40] }); + assertEquals([12, 18], g.xAxisRange()); + assertEquals([10, 40], g.yAxisRange(0)); + + g.updateOptions({ valueRange: [10, undefined] }); + assertEquals([12, 18], g.xAxisRange()); + assertEquals([10, 44.2], g.yAxisRange(0)); + + g.updateOptions({ valueRange: [10, 40] }); + assertEquals([12, 18], g.xAxisRange()); + assertEquals([10, 40], g.yAxisRange(0)); + g.updateOptions({ }); assertEquals([12, 18], g.xAxisRange()); assertEquals([10, 40], g.yAxisRange(0)); diff --git a/dygraph.js b/dygraph.js index b516f5e..71bacbf 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2571,8 +2571,8 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { } else if (axis.valueRange) { // This is a user-set value range for this axis. axis.computedValueRange = [ - !isNaN(axis.valueRange[0]) ? axis.valueRange[0] : axis.extremeRange[0], - !isNaN(axis.valueRange[1]) ? axis.valueRange[1] : axis.extremeRange[1] + !isNaN(axis.valueRange[0]) && axis.valueRange[0] !== null && axis.valueRange[0] !== undefined ? axis.valueRange[0] : axis.extremeRange[0], + !isNaN(axis.valueRange[1]) && axis.valueRange[1] !== null && axis.valueRange[1] !== undefined ? axis.valueRange[1] : axis.extremeRange[1] ]; } else { axis.computedValueRange = axis.extremeRange;