From: LeeLenaleee <39033624+LeeLenaleee@users.noreply.github.com> Date: Sat, 30 Jan 2021 16:02:08 +0000 (+0100) Subject: feature: choose custom point style for bar legend display (#8341) X-Git-Tag: v3.0.0-beta.10~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc312d0dbcb2713ca6903d33cf59a5235a072b2e;p=thirdparty%2FChart.js.git feature: choose custom point style for bar legend display (#8341) * add feature to choose custom point style for bar legend display * add documentation and type * the docs are in the right place now --- diff --git a/docs/docs/charts/bar.mdx b/docs/docs/charts/bar.mdx index bf49cc6ef..142e752be 100644 --- a/docs/docs/charts/bar.mdx +++ b/docs/docs/charts/bar.mdx @@ -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 diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 89d4d5918..24bd67566 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -522,6 +522,7 @@ BarController.defaults = { 'categoryPercentage', 'maxBarThickness', 'minBarLength', + 'pointStyle' ], interaction: { mode: 'index' diff --git a/test/specs/plugin.legend.tests.js b/test/specs/plugin.legend.tests.js index 79d149c21..198c3785a 100644 --- a/test/specs/plugin.legend.tests.js +++ b/test/specs/plugin.legend.tests.js @@ -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() { }); }); }); - diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index a018fa5ef..cf2d6dd50 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -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 {