From: Dan Vanderkam Date: Fri, 8 Feb 2013 22:45:36 +0000 (-0500) Subject: Slightly scary change to fix issue 426 X-Git-Tag: v1.0.0~95 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=5d2acf298cb95cbcf42aaee980a516d13a961474;p=dygraphs.git Slightly scary change to fix issue 426 --- diff --git a/auto_tests/tests/rolling_average.js b/auto_tests/tests/rolling_average.js index e798ca6..c0af8f9 100644 --- a/auto_tests/tests/rolling_average.js +++ b/auto_tests/tests/rolling_average.js @@ -81,3 +81,22 @@ rollingAverageTestCase.prototype.testRollBoxDoesntDisapper = function() { assertEquals("1", roll_box[0].value); }; +// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=426 +rollingAverageTestCase.prototype.testRollShortFractions = function() { + var opts = { + customBars: true, + labels: ['x', 'A'] + }; + var data1 = [ [1, [1, 10, 20]] ]; + var data2 = [ [1, [1, 10, 20]], + [2, [1, 20, 30]], + ]; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data1, opts); + + var rolled1 = g.rollingAverage(data1, 1); + var rolled2 = g.rollingAverage(data2, 1); + + assertEquals(rolled1[0], rolled2[0]); +}; diff --git a/dygraph.js b/dygraph.js index eba57db..3de6776 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2664,8 +2664,6 @@ Dygraph.prototype.extractSeries_ = function(rawData, i, logScale) { * data */ Dygraph.prototype.rollingAverage = function(originalData, rollPeriod) { - if (originalData.length < 2) - return originalData; rollPeriod = Math.min(rollPeriod, originalData.length); var rollingData = []; var sigma = this.attr_("sigma");