]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update bar data type to comply with floating bar charts data (#10652)
authorLonylis <yvan.nicolas@gmail.com>
Tue, 6 Sep 2022 13:42:04 +0000 (09:42 -0400)
committerGitHub <noreply@github.com>
Tue, 6 Sep 2022 13:42:04 +0000 (09:42 -0400)
* 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 <jaccoberg2281@gmail.com>
* floating bar chart data validation

Co-authored-by: Jacco van den Berg <jaccoberg2281@gmail.com>
types/index.d.ts
types/tests/controllers/bar_floating_data.ts [new file with mode: 0644]

index a992e62f1332183614acb9248ae524a324b930ff..eb8f7dd1487faf27a2e3046b1cde4904c790386b 100644 (file)
@@ -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 (file)
index 0000000..91380a8
--- /dev/null
@@ -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]]
+    }]
+  },
+});