Skip to content

Commit

Permalink
fix: series fill & stroke being inconsistent when render time > last …
Browse files Browse the repository at this point in the history
…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`.
  • Loading branch information
WofWca committed Oct 8, 2021
1 parent 6641ce5 commit 2ba907c
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions smoothie.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 2ba907c

Please sign in to comment.