From 06c0e1ee108f0fa627b6b2c39f70cf64869ce91d Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 25 Nov 2013 13:59:47 -0800 Subject: [PATCH 1/1] Speed up renerding of stacked graph by avoiding the loop in updateNextPoint(), when stackedGraphNaNFill = 'none'. --- dygraph.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) 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; } -- 2.7.4