]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: correct typing for doughnut, pie, and polarArea charts (#11521)
authorDustinEwan <dustineewan@gmail.com>
Mon, 18 Nov 2024 20:43:17 +0000 (14:43 -0600)
committerGitHub <noreply@github.com>
Mon, 18 Nov 2024 20:43:17 +0000 (15:43 -0500)
* fix(#10896): correct typing for doughnut, pie, and polarArea charts

* formatting

src/types/index.d.ts
test/types/options.ts

index 0fbe356a3aec232eec7f5a3db2631a509e1448e2..c59a39c4581e54b303c1bc02a4d8ef2df2992a96 100644 (file)
@@ -281,7 +281,7 @@ export interface DoughnutControllerDatasetOptions
   spacing: number;
 }
 
-export interface DoughnutAnimationOptions {
+export interface DoughnutAnimationOptions extends AnimationSpec<'doughnut'> {
   /**
    *   If true, the chart will animate in with a rotation animation. This property is in the options.animation object.
    * @default true
index a3b612f625dbd5491c31c8e191011afe289e19d5..21d0ccf17c770dcdc1eaeeac652a67adad13ce88 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../src/types.js';
+import { Chart, ChartOptions, ChartType, DoughnutControllerChartOptions } from '../../src/types.js';
 
 const chart = new Chart('test', {
   type: 'bar',
@@ -31,3 +31,15 @@ const chart = new Chart('test', {
     }
   }
 });
+
+const doughnutOptions: DoughnutControllerChartOptions = {
+  circumference: 360,
+  cutout: '50%',
+  offset: 0,
+  radius: 100,
+  rotation: 0,
+  spacing: 0,
+  animation: false,
+};
+
+const chartOptions: ChartOptions<ChartType> = doughnutOptions;