From 21305e2883c55e64c949de5a8cf9edd333f48cd7 Mon Sep 17 00:00:00 2001 From: Lonylis Date: Tue, 6 Sep 2022 09:42:04 -0400 Subject: [PATCH] Update bar data type to comply with floating bar charts data (#10652) * Update index.d.ts Floating bars charts can take an array of array. https://www.chartjs.org/docs/latest/samples/bar/floating.html * Update types/index.d.ts Co-authored-by: Jacco van den Berg * floating bar chart data validation Co-authored-by: Jacco van den Berg --- types/index.d.ts | 2 +- types/tests/controllers/bar_floating_data.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 types/tests/controllers/bar_floating_data.ts diff --git a/types/index.d.ts b/types/index.d.ts index a992e62f1..eb8f7dd14 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3503,7 +3503,7 @@ export interface ChartTypeRegistry { bar: { chartOptions: BarControllerChartOptions; datasetOptions: BarControllerDatasetOptions; - defaultDataPoint: number | null; + defaultDataPoint: number | [number, number] | null; metaExtensions: {}; parsedDataType: BarParsedData, scales: keyof CartesianScaleTypeRegistry; diff --git a/types/tests/controllers/bar_floating_data.ts b/types/tests/controllers/bar_floating_data.ts new file mode 100644 index 000000000..91380a85c --- /dev/null +++ b/types/tests/controllers/bar_floating_data.ts @@ -0,0 +1,11 @@ +import { Chart } from '../../../src/types'; + +const chart = new Chart('id', { + type: 'bar', + data: { + labels: ['1', '2', '3'], + datasets: [{ + data: [[1, 2], [3, 4], [5, 6]] + }] + }, +});