From cedec28b58b093fe96fe15de833bbed6bf79fe9f Mon Sep 17 00:00:00 2001 From: WofWca Date: Fri, 8 Oct 2021 15:54:14 +0800 Subject: [PATCH 1/2] fix: series fill & stroke being inconsistent for last data time < render 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 82e4469..54b179c 100644 --- a/smoothie.js +++ b/smoothie.js @@ -999,26 +999,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) { From fd47202d2910790b9e77c5ed41d21ededb45443c Mon Sep 17 00:00:00 2001 From: WofWca Date: Fri, 8 Oct 2021 16:17:49 +0800 Subject: [PATCH 2/2] docs: update changelog --- smoothie.js | 1 + 1 file changed, 1 insertion(+) diff --git a/smoothie.js b/smoothie.js index 54b179c..5c41ec2 100644 --- a/smoothie.js +++ b/smoothie.js @@ -97,6 +97,7 @@ * Allow setting interpolation per time series, by @WofWca (#123) * Fix a memory leak appearing when some `timeSeries.disabled === true`, by @WofWca (#132) * Improve performance, by @WofWca (#135) + * Fix series fill & stroke being inconsistent for last data time < render time, by @WofWca (#138) */ ;(function(exports) {