]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix control points on animated line w/o border (#9592)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Thu, 2 Sep 2021 00:39:48 +0000 (03:39 +0300)
committerGitHub <noreply@github.com>
Thu, 2 Sep 2021 00:39:48 +0000 (20:39 -0400)
Co-authored-by: Jukka Kurkela <jukka.kurkela@scmbest.fi>
src/elements/element.line.js
test/fixtures/controller.line/fill/no-border.js [new file with mode: 0644]
test/fixtures/controller.line/fill/no-border.png [new file with mode: 0644]

index c09548c41ce12067d02593d6d108c34e9e3d2fa5..55752c6c1997c221255d63a4ac3856b0f82e5079 100644 (file)
@@ -395,15 +395,13 @@ export default class LineElement extends Element {
     const options = me.options || {};
     const points = me.points || [];
 
-    if (!points.length || !options.borderWidth) {
-      return;
-    }
+    if (points.length && options.borderWidth) {
+      ctx.save();
 
-    ctx.save();
+      draw(ctx, me, start, count);
 
-    draw(ctx, me, start, count);
-
-    ctx.restore();
+      ctx.restore();
+    }
 
     if (me.animated) {
       // When line is animated, the control points and path are not cached.
diff --git a/test/fixtures/controller.line/fill/no-border.js b/test/fixtures/controller.line/fill/no-border.js
new file mode 100644 (file)
index 0000000..5846762
--- /dev/null
@@ -0,0 +1,41 @@
+module.exports = {
+  config: {
+    type: 'line',
+    data: {
+      labels: [0, 1, 2, 3, 4, 5],
+      datasets: [
+        {
+          data: [12, 19, 3, 5, 2, 3],
+          backgroundColor: '#ff0000',
+          borderWidth: 0,
+          tension: 0.4,
+          fill: true
+        },
+      ]
+    },
+    options: {
+      animation: {
+        duration: 1
+      },
+      scales: {
+        x: {display: false},
+        y: {display: false}
+      },
+      plugins: {
+        legend: false,
+        title: false,
+        tooltip: false,
+        filler: true
+      }
+    }
+  },
+  options: {
+    canvas: {
+      height: 256,
+      width: 512
+    },
+    run() {
+      return new Promise(resolve => setTimeout(resolve, 50));
+    }
+  }
+};
diff --git a/test/fixtures/controller.line/fill/no-border.png b/test/fixtures/controller.line/fill/no-border.png
new file mode 100644 (file)
index 0000000..b140cea
Binary files /dev/null and b/test/fixtures/controller.line/fill/no-border.png differ