From: Dan Vanderkam Date: Tue, 17 Jul 2012 17:06:14 +0000 (-0500) Subject: remove if statement X-Git-Tag: v1.0.0~229 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=16febe6b47a137dee62bb09eedc1a7d13f4ec187;p=dygraphs.git remove if statement --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 0d0f895..efae1cf 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -554,62 +554,60 @@ DygraphCanvasRenderer.prototype.drawFillBars_ = function(points) { ctx.beginPath(); while(iter.hasNext) { var point = iter.next(); - if (point.name == setName) { // TODO(klausw): this is always true - if (!Dygraph.isOK(point.y)) { - prevX = NaN; - continue; - } - if (stackedGraph) { - currBaseline = baseline[point.canvasx]; - var lastY; - if (currBaseline === undefined) { - lastY = axisY; + if (!Dygraph.isOK(point.y)) { + prevX = NaN; + continue; + } + if (stackedGraph) { + currBaseline = baseline[point.canvasx]; + var lastY; + if (currBaseline === undefined) { + lastY = axisY; + } else { + if(stepPlot) { + lastY = currBaseline[0]; } else { - if(stepPlot) { - lastY = currBaseline[0]; - } else { - lastY = currBaseline; - } + lastY = currBaseline; } - newYs = [ point.canvasy, lastY ]; + } + newYs = [ point.canvasy, lastY ]; - if(stepPlot) { - // Step plots must keep track of the top and bottom of - // the baseline at each point. - if(prevYs[0] === -1) { - baseline[point.canvasx] = [ point.canvasy, axisY ]; - } else { - baseline[point.canvasx] = [ point.canvasy, prevYs[0] ]; - } + if(stepPlot) { + // Step plots must keep track of the top and bottom of + // the baseline at each point. + if(prevYs[0] === -1) { + baseline[point.canvasx] = [ point.canvasy, axisY ]; } else { - baseline[point.canvasx] = point.canvasy; + baseline[point.canvasx] = [ point.canvasy, prevYs[0] ]; } - } else { - newYs = [ point.canvasy, axisY ]; + baseline[point.canvasx] = point.canvasy; } - if (!isNaN(prevX)) { - ctx.moveTo(prevX, prevYs[0]); - if (stepPlot) { - ctx.lineTo(point.canvasx, prevYs[0]); - if(currBaseline) { - // Draw to the bottom of the baseline - ctx.lineTo(point.canvasx, currBaseline[1]); - } else { - ctx.lineTo(point.canvasx, newYs[1]); - } + } else { + newYs = [ point.canvasy, axisY ]; + } + if (!isNaN(prevX)) { + ctx.moveTo(prevX, prevYs[0]); + + if (stepPlot) { + ctx.lineTo(point.canvasx, prevYs[0]); + if(currBaseline) { + // Draw to the bottom of the baseline + ctx.lineTo(point.canvasx, currBaseline[1]); } else { - ctx.lineTo(point.canvasx, newYs[0]); ctx.lineTo(point.canvasx, newYs[1]); } - - ctx.lineTo(prevX, prevYs[1]); - ctx.closePath(); + } else { + ctx.lineTo(point.canvasx, newYs[0]); + ctx.lineTo(point.canvasx, newYs[1]); } - prevYs = newYs; - prevX = point.canvasx; + + ctx.lineTo(prevX, prevYs[1]); + ctx.closePath(); } + prevYs = newYs; + prevX = point.canvasx; } ctx.fill(); }