]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Pointstyle false (#10886)
authorJacco van den Berg <jaccoberg2281@gmail.com>
Fri, 18 Nov 2022 18:14:47 +0000 (19:14 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Nov 2022 18:14:47 +0000 (13:14 -0500)
* fix-#10755

* none to false

* str to bool

* str to bool

* 10/10

* fix test

Co-authored-by: puneetkathar1 <puneetkathar1@gmail.com>
Co-authored-by: Puneet Kathar <73285338+puneetkathar1@users.noreply.github.com>
12 files changed:
docs/configuration/elements.md
docs/samples/line/point-styling.md
src/helpers/helpers.canvas.js
test/fixtures/controller.line/pointStyle/indexable.js
test/fixtures/controller.line/pointStyle/indexable.png
test/fixtures/controller.radar/pointStyle/indexable.js
test/fixtures/controller.radar/pointStyle/indexable.png
test/fixtures/element.point/rotation.js
test/fixtures/element.point/rotation.png
test/fixtures/plugin.tooltip/point-style.js
test/fixtures/plugin.tooltip/point-style.png
types/index.d.ts

index e37a12e27ec0ab8cd31a5a1667478bab7fd77e97..4b2a08f940caf78f329c5f5dbaa772e56adcb4c6 100644 (file)
@@ -47,6 +47,7 @@ When a string is provided, the following values are supported:
 - `'rectRot'`
 - `'star'`
 - `'triangle'`
+- `false`
 
 If the value is an image or a canvas element, that image or canvas element is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).
 
index 22f63b3f10a52f286b6bf6e303e35493fd4a4cc5..714cd052bd54aab7d7e571b8b9072141d4b5f61b 100644 (file)
@@ -92,6 +92,15 @@ const actions = [
       });
       chart.update();
     }
+  },
+  {
+    name: 'pointStyle: false',
+    handler: (chart) => {
+      chart.data.datasets.forEach(dataset => {
+        dataset.pointStyle = false;
+      });
+      chart.update();
+    }
   }
 ];
 // </block:actions>
index 40ada9bbb69ce8489e2b60f00416555abaa06003..ce3bf2c1f0632fa3997ea85be3df55b32173887b 100644 (file)
@@ -256,6 +256,9 @@ export function drawPointLegend(ctx, options, x, y, w) {
     ctx.moveTo(x, y);
     ctx.lineTo(x + Math.cos(rad) * (w ? w / 2 : radius), y + Math.sin(rad) * radius);
     break;
+  case false:
+    ctx.closePath();
+    break;
   }
 
   ctx.fill();
index 852115c9a3a645d50ddfc956142e1e5041572156..93a04a6f4a51995f0c67181031487e4d3ddba2b2 100644 (file)
@@ -2,11 +2,11 @@ module.exports = {
   config: {
     type: 'line',
     data: {
-      labels: [0, 1, 2, 3, 4, 5],
+      labels: [0, 1, 2, 3, 4, 5, 6],
       datasets: [
         {
           // option in dataset
-          data: [0, 5, 10, null, -10, -5],
+          data: [0, 5, 10, null, -10, -5, 0],
           pointBackgroundColor: '#ff0000',
           pointBorderColor: '#ff0000',
           pointStyle: [
@@ -16,11 +16,12 @@ module.exports = {
             'dash',
             'line',
             'rect',
+            false
           ]
         },
         {
           // option in element (fallback)
-          data: [4, -5, -10, null, 10, 5],
+          data: [4, -5, -10, null, 10, 5, -4],
         }
       ]
     },
index 184aaf56c34a3f7f3a0859e587dfcf57b9bf7d52..6a6dc0021f7118a75085d6f0c4d7721060b1a6bd 100644 (file)
Binary files a/test/fixtures/controller.line/pointStyle/indexable.png and b/test/fixtures/controller.line/pointStyle/indexable.png differ
index 65afe0be2489272fc7d597f2a20c202e3d94f715..48101e997de229c04d4812b882d2050fd16fc75a 100644 (file)
@@ -2,11 +2,11 @@ module.exports = {
   config: {
     type: 'radar',
     data: {
-      labels: [0, 1, 2, 3, 4, 5],
+      labels: [0, 1, 2, 3, 4, 5, 6],
       datasets: [
         {
           // option in dataset
-          data: [0, 5, 10, null, -10, -5],
+          data: [0, 5, 10, null, -10, -5, 0],
           pointBackgroundColor: '#ff0000',
           pointBorderColor: '#ff0000',
           pointStyle: [
@@ -16,11 +16,12 @@ module.exports = {
             'dash',
             'line',
             'rect',
+            false
           ]
         },
         {
           // option in element (fallback)
-          data: [4, -5, -10, null, 10, 5],
+          data: [4, -5, -10, null, 10, 5, -4],
         }
       ]
     },
index c8e040214555bc292d68beb59a648f7c5028a449..7c3a7460f6999f8c46f5ae5d5b1401a7db30a69e 100644 (file)
Binary files a/test/fixtures/controller.radar/pointStyle/indexable.png and b/test/fixtures/controller.radar/pointStyle/indexable.png differ
index 6d2265e1ee237cbebb26184ca299c2b41e044ba8..e5fffba12ebc344acc8e7a06e98c45e5601afaca 100644 (file)
@@ -1,10 +1,10 @@
 var gradient;
 
-var datasets = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle'].map(function(style, y) {
+var datasets = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle', false].map(function(style, y) {
   return {
     pointStyle: style,
     data: Array.apply(null, Array(17)).map(function(v, x) {
-      return {x: x, y: 10 - y};
+      return {x: x, y: 11 - y};
     })
   };
 });
index 579c712ecf621a087cf574b48e2c14be27a28aa7..11424fffbef7f1e416575df23eef48af4d0d0335 100644 (file)
Binary files a/test/fixtures/element.point/rotation.png and b/test/fixtures/element.point/rotation.png differ
index 255e4f153b8013d91109bc457a4b4493384bd510..f8a07167138a460c5c4aa87043d01e7fcae3595b 100644 (file)
@@ -1,4 +1,4 @@
-const pointStyles = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle'];
+const pointStyles = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle', false];
 
 function newDataset(pointStyle, i) {
   return {
index 39b0fad1ba2200c0141e27fb4ce9775964ca507d..e11b8cc5350e6b040f338e4d28b35ea289a619ad 100644 (file)
Binary files a/test/fixtures/plugin.tooltip/point-style.png and b/test/fixtures/plugin.tooltip/point-style.png differ
index 671f3e27f6f8613b8bc1f102469cca0dfc8721d3..986b1cfec51641828f3e3618ccfd07dbd05daff5 100644 (file)
@@ -1823,6 +1823,7 @@ export type PointStyle =
   | 'rectRot'
   | 'star'
   | 'triangle'
+  | false
   | HTMLImageElement
   | HTMLCanvasElement;