]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
feature: choose custom point style for bar legend display (#8341)
authorLeeLenaleee <39033624+LeeLenaleee@users.noreply.github.com>
Sat, 30 Jan 2021 16:02:08 +0000 (17:02 +0100)
committerGitHub <noreply@github.com>
Sat, 30 Jan 2021 16:02:08 +0000 (11:02 -0500)
* add feature to choose custom point style for bar legend display
* add documentation and type
* the docs are in the right place now

docs/docs/charts/bar.mdx
src/controllers/controller.bar.js
test/specs/plugin.legend.tests.js
types/index.esm.d.ts

index bf49cc6ef94c6cecd7ff2a896c1c9340a5662836..142e752bef2c1f5b8d65a2a97bd166ed842cc5dc 100644 (file)
@@ -93,6 +93,7 @@ the color of the bars is generally set this way.
 | [`indexAxis`](#general) | `string` | - | - | `'x'`
 | [`label`](#general) | `string` | - | - | `''`
 | [`order`](#general) | `number` | - | - | `0`
+| [`pointStyle`](../configuration/elements.md#point-styles) | `string`\|`Image` | Yes | False | `'circle'`
 | [`xAxisID`](#general) | `string` | - | - | first x axis
 | [`yAxisID`](#general) | `string` | - | - | first y axis
 
index 89d4d591802926dc28539953e88ebde2c4289ac9..24bd67566591624f805ec619873c064a6e85a483 100644 (file)
@@ -522,6 +522,7 @@ BarController.defaults = {
                'categoryPercentage',
                'maxBarThickness',
                'minBarLength',
+               'pointStyle'
        ],
        interaction: {
                mode: 'index'
index 79d149c210bc882d364d00285b29e5ca05c33793..198c3785af758af01156aa009730686a84137899 100644 (file)
@@ -95,7 +95,7 @@ describe('Legend block tests', function() {
                        lineJoin: undefined,
                        lineWidth: 10,
                        strokeStyle: 'green',
-                       pointStyle: undefined,
+                       pointStyle: 'crossRot',
                        rotation: undefined,
                        datasetIndex: 2
                }]);
@@ -311,7 +311,7 @@ describe('Legend block tests', function() {
                        lineJoin: undefined,
                        lineWidth: 10,
                        strokeStyle: 'green',
-                       pointStyle: undefined,
+                       pointStyle: 'crossRot',
                        rotation: undefined,
                        datasetIndex: 2
                }]);
@@ -887,4 +887,3 @@ describe('Legend block tests', function() {
                });
        });
 });
-
index a018fa5ef24e1fb2d623490e06c4f735c12d2777..cf2d6dd50eb55d116a5aa7cca034bfb94ea3be8e 100644 (file)
@@ -125,6 +125,12 @@ export interface BarControllerDatasetOptions
         * Set this to ensure that bars have a minimum length in pixels.
         */
        minBarLength: number;
+
+       /**
+        * Point style for the legend
+        * @default 'circle;
+        */
+       pointStyle: PointStyle;
 }
 
 export interface BarControllerChartOptions {