]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove unreachable code paths from plugins (#8513)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Wed, 24 Feb 2021 19:33:07 +0000 (21:33 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Feb 2021 19:33:07 +0000 (21:33 +0200)
src/plugins/plugin.filler.js
src/plugins/plugin.title.js

index 9b725b3f2519a8408b52f08d6086e70b60924605..e91551c78fe40ac477f1d3b40f6d16e3c85a7e3a 100644 (file)
@@ -114,24 +114,18 @@ class simpleArc {
   pathSegment(ctx, bounds, opts) {
     const {x, y, radius} = this;
     bounds = bounds || {start: 0, end: TAU};
-    if (opts.reverse) {
-      ctx.arc(x, y, radius, bounds.end, bounds.start, true);
-    } else {
-      ctx.arc(x, y, radius, bounds.start, bounds.end);
-    }
+    ctx.arc(x, y, radius, bounds.end, bounds.start, true);
     return !opts.bounds;
   }
 
-  interpolate(point, property) {
+  interpolate(point) {
     const {x, y, radius} = this;
     const angle = point.angle;
-    if (property === 'angle') {
-      return {
-        x: x + Math.cos(angle) * radius,
-        y: y + Math.sin(angle) * radius,
-        angle
-      };
-    }
+    return {
+      x: x + Math.cos(angle) * radius,
+      y: y + Math.sin(angle) * radius,
+      angle
+    };
   }
 }
 
index 662674459c4c1f9b005e3d2e4623060c88055265..3872a12d736306ed4dc85297009424e19d8f02d9 100644 (file)
@@ -119,24 +119,6 @@ function createTitle(chart, titleOpts) {
   chart.titleBlock = title;
 }
 
-function removeTitle(chart) {
-  const title = chart.titleBlock;
-  if (title) {
-    layouts.removeBox(chart, title);
-    delete chart.titleBlock;
-  }
-}
-
-function createOrUpdateTitle(chart, options) {
-  const title = chart.titleBlock;
-  if (title) {
-    layouts.configure(chart, title, options);
-    title.options = options;
-  } else {
-    createTitle(chart, options);
-  }
-}
-
 export default {
   id: 'title',
 
@@ -157,11 +139,9 @@ export default {
   },
 
   beforeUpdate(chart, _args, options) {
-    if (options === false) {
-      removeTitle(chart);
-    } else {
-      createOrUpdateTitle(chart, options);
-    }
+    const title = chart.titleBlock;
+    layouts.configure(chart, title, options);
+    title.options = options;
   },
 
   defaults: {