From 2ba907c1122452f7c2dd96ad8785e2c773c83667 Mon Sep 17 00:00:00 2001 From: WofWca Date: Fri, 8 Oct 2021 15:54:14 +0800 Subject: [PATCH] fix: series fill & stroke being inconsistent when render time > last data time It would depend on `scrollBackwards` and `fillStyle` being `undefined` or not. Depending on this, it would either continue the line up to the edge of the canvas or leave it at `lastX`. This makes it so that it is always left at `lastX`. --- smoothie.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/smoothie.js b/smoothie.js index 8ba2aca..c722ee6 100644 --- a/smoothie.js +++ b/smoothie.js @@ -998,26 +998,20 @@ lastX = x; lastY = y; } - if (seriesOptions.fillStyle) { - // Close up the fill region. - if (chartOptions.scrollBackwards) { - context.lineTo(lastX, dimensions.height + seriesOptions.lineWidth); - context.lineTo(firstX, dimensions.height + seriesOptions.lineWidth); - context.lineTo(firstX, firstY); - } else { - context.lineTo(dimensions.width + seriesOptions.lineWidth + 1, lastY); - context.lineTo(dimensions.width + seriesOptions.lineWidth + 1, dimensions.height + seriesOptions.lineWidth + 1); - context.lineTo(firstX, dimensions.height + seriesOptions.lineWidth); - } - context.fillStyle = seriesOptions.fillStyle; - context.fill(); - } - if (seriesOptions.strokeStyle && seriesOptions.strokeStyle !== 'none') { context.lineWidth = seriesOptions.lineWidth; context.strokeStyle = seriesOptions.strokeStyle; context.stroke(); } + + if (seriesOptions.fillStyle) { + // Close up the fill region. + context.lineTo(lastX, dimensions.height + seriesOptions.lineWidth + 1); + context.lineTo(firstX, dimensions.height + seriesOptions.lineWidth + 1); + + context.fillStyle = seriesOptions.fillStyle; + context.fill(); + } } if (chartOptions.tooltip && this.mouseX >= 0) {