From ccecde931c59699a62c0e83651dc28ac680f83ab Mon Sep 17 00:00:00 2001 From: Klaus Weidner Date: Sun, 10 Feb 2013 15:10:06 -0800 Subject: [PATCH] Address code review comments --- auto_tests/tests/pathological_cases.js | 4 ++-- auto_tests/tests/range_tests.js | 35 ++++++++++++++++++++++++++++++++++ dygraph.js | 15 ++------------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/auto_tests/tests/pathological_cases.js b/auto_tests/tests/pathological_cases.js index 502c8fd..08d4661 100644 --- a/auto_tests/tests/pathological_cases.js +++ b/auto_tests/tests/pathological_cases.js @@ -68,8 +68,8 @@ pathologicalCasesTestCase.prototype.testCombinations = function() { padded: { includeZero: true, drawAxesAtZero: true, - xRangePad: 0.02, - yRangePad: 0.04 + xRangePad: 2, + yRangePad: 4 } }; diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index 2b2e59a..c652af7 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -368,3 +368,38 @@ RangeTestCase.prototype.testLogscalePad = function() { [[-10, 10], [10, 10], [30, 1000]], [-10, 30], [5.01691, 1993.25801]); }; + +/** + * Verify scrolling all-zero region, traditional. + */ +RangeTestCase.prototype.testZeroScroll = function() { + g = new Dygraph( + document.getElementById("graph"), + "X,Y\n" + + "1,0\n" + + "8,0\n" + + "9,0.1\n", + { + drawAxesAtZero: true, + animatedZooms: true, + avoidMinZero: true + }); +}; + +/** + * Verify scrolling all-zero region, new-style. + */ +RangeTestCase.prototype.testZeroScroll2 = function() { + g = new Dygraph( + document.getElementById("graph"), + "X,Y\n" + + "1,0\n" + + "8,0\n" + + "9,0.1\n", + { + animatedZooms: true, + drawAxesAtZero: true, + xRangePad: 4, + yRangePad: 4 + }); +}; diff --git a/dygraph.js b/dygraph.js index 0c00c84..0b01dd8 100644 --- a/dygraph.js +++ b/dygraph.js @@ -660,7 +660,7 @@ Dygraph.prototype.xAxisRange = function() { */ Dygraph.prototype.xAxisExtremes = function() { var pad = this.attr_('xRangePad') / this.plotter_.area.w; - if (!this.numRows() > 0) { + if (this.numRows() == 0) { return [0 - pad, 1 + pad]; } var left = this.rawData_[0][0]; @@ -900,17 +900,6 @@ Dygraph.prototype.numRows = function() { }; /** - * Returns the full range of the x-axis, as determined by the most extreme - * values in the data set. Not affected by zooming, visibility, etc. - * TODO(danvk): merge w/ xAxisExtremes - * @return { Array } A [low, high] pair - * @private - */ -Dygraph.prototype.fullXRange_ = function() { - return this.xAxisExtremes(); -}; - -/** * Returns the value in the given row and column. If the row and column exceed * the bounds on the data, returns null. Also returns null if the value is * missing. @@ -2092,7 +2081,7 @@ Dygraph.prototype.addXTicks_ = function() { if (this.dateWindow_) { range = [this.dateWindow_[0], this.dateWindow_[1]]; } else { - range = this.fullXRange_(); + range = this.xAxisExtremes(); } var xAxisOptionsView = this.optionsViewForAxis_('x'); -- 2.7.4