smoothie icon indicating copy to clipboard operation
smoothie copied to clipboard

fillStyle + negative minValue = BUG

Open socketpair opened this issue 8 years ago • 4 comments

Instead of filling from line y=0, it fills from bottom of the screen. This is a bug (!)

I cannot draw two filled series one of the between [0,100] and other [-100, 0] since filled area of that series will overlap, but should not (!)

socketpair avatar Dec 07 '15 20:12 socketpair

Here is the patch:

--- smoothie.js.1<----->2015-02-15 01:26:37.000000000 +0500
+++ smoothie.js>2015-12-08 02:15:18.206009660 +0500
@@ -702,8 +702,9 @@
         if (seriesOptions.fillStyle) {
           // Close up the fill region.
           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.lineTo(dimensions.width + seriesOptions.lineWidth + 1, valueToYPixel(0));
+          context.lineTo(firstX,                                         valueToYPixel(0));
+
           context.fillStyle = seriesOptions.fillStyle;
           context.fill();
         }

It works as I expect, Thanks for clear sources, that everyone can understand.

But, it maybe off-by-one errors, since I do not understand meaning of seriesOptions.lineWidth + 1 or seriesOptions.lineWidth. Please fix that and merge!

socketpair avatar Dec 07 '15 21:12 socketpair

Maybe you should add an option to switch between old and this new behaviour.

socketpair avatar Dec 07 '15 21:12 socketpair

I don't think you can call this a bug.

WofWca avatar Sep 14 '21 15:09 WofWca

6 years... I forgot what I wanted...

socketpair avatar Sep 14 '21 17:09 socketpair