From: Shawn Date: Mon, 25 Nov 2013 21:59:47 +0000 (-0800) Subject: Speed up renerding of stacked graph by avoiding the loop in X-Git-Tag: v1.1.0~70^2~1^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=06c0e1ee108f0fa627b6b2c39f70cf64869ce91d;p=dygraphs.git Speed up renerding of stacked graph by avoiding the loop in updateNextPoint(), when stackedGraphNaNFill = 'none'. --- diff --git a/dygraph.js b/dygraph.js index a96b98f..85885e2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2366,19 +2366,24 @@ Dygraph.stackPoints_ = function( var actualYval = point.yval; if (isNaN(actualYval) || actualYval === null) { - // Interpolate/extend for stacking purposes if possible. - updateNextPoint(i); - if (prevPoint && nextPoint && fillMethod != 'none') { - // Use linear interpolation between prevPoint and nextPoint. - actualYval = prevPoint.yval + (nextPoint.yval - prevPoint.yval) * - ((xval - prevPoint.xval) / (nextPoint.xval - prevPoint.xval)); - } else if (prevPoint && fillMethod == 'all') { - actualYval = prevPoint.yval; - } else if (nextPoint && fillMethod == 'all') { - actualYval = nextPoint.yval; - } else { + if(fillMethod == 'none') { actualYval = 0; } + else { + // Interpolate/extend for stacking purposes if possible. + updateNextPoint(i); + if (prevPoint && nextPoint && fillMethod != 'none') { + // Use linear interpolation between prevPoint and nextPoint. + actualYval = prevPoint.yval + (nextPoint.yval - prevPoint.yval) * + ((xval - prevPoint.xval) / (nextPoint.xval - prevPoint.xval)); + } else if (prevPoint && fillMethod == 'all') { + actualYval = prevPoint.yval; + } else if (nextPoint && fillMethod == 'all') { + actualYval = nextPoint.yval; + } else { + actualYval = 0; + } + } } else { prevPoint = point; }