From d0395bcd2f7bfde7cd0bb5bc7cd8b2d955575482 Mon Sep 17 00:00:00 2001 From: Dustin Ewan Date: Thu, 28 Sep 2023 11:36:38 -0500 Subject: [PATCH 1/2] fix(#10896): correct typing for doughnut, pie, and polarArea charts --- src/types/index.d.ts | 2 +- test/types/options.ts | 48 ++++++++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 1a652c6dc19..43dc8f684b1 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -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 diff --git a/test/types/options.ts b/test/types/options.ts index a3b612f625d..5d8c9eb71ba 100644 --- a/test/types/options.ts +++ b/test/types/options.ts @@ -1,33 +1,53 @@ -import { Chart } from '../../src/types.js'; +import { + Chart, + ChartOptions, + ChartType, + DoughnutControllerChartOptions, +} from '../../src/types.js'; const chart = new Chart('test', { type: 'bar', data: { labels: ['a'], - datasets: [{ - data: [1], - }, { - type: 'line', - data: [{ x: 1, y: 1 }] - }] + datasets: [ + { + data: [1], + }, + { + type: 'line', + data: [{ x: 1, y: 1 }], + }, + ], }, options: { animation: { - duration: 500 + duration: 500, }, backgroundColor: 'red', datasets: { line: { animation: { - duration: 600 + duration: 600, }, backgroundColor: 'blue', - } + }, }, elements: { point: { - backgroundColor: 'red' - } - } - } + backgroundColor: 'red', + }, + }, + }, }); + +const doughnutOptions: DoughnutControllerChartOptions = { + circumference: 360, + cutout: '50%', + offset: 0, + radius: 100, + rotation: 0, + spacing: 0, + animation: false, +}; + +const chartOptions: ChartOptions = doughnutOptions; From 656f66e4c3318b9adf953e43905a13208124a445 Mon Sep 17 00:00:00 2001 From: Dustin Ewan Date: Thu, 28 Sep 2023 11:39:05 -0500 Subject: [PATCH 2/2] formatting --- test/types/options.ts | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/test/types/options.ts b/test/types/options.ts index 5d8c9eb71ba..21d0ccf17c7 100644 --- a/test/types/options.ts +++ b/test/types/options.ts @@ -1,43 +1,35 @@ -import { - Chart, - ChartOptions, - ChartType, - DoughnutControllerChartOptions, -} from '../../src/types.js'; +import { Chart, ChartOptions, ChartType, DoughnutControllerChartOptions } from '../../src/types.js'; const chart = new Chart('test', { type: 'bar', data: { labels: ['a'], - datasets: [ - { - data: [1], - }, - { - type: 'line', - data: [{ x: 1, y: 1 }], - }, - ], + datasets: [{ + data: [1], + }, { + type: 'line', + data: [{ x: 1, y: 1 }] + }] }, options: { animation: { - duration: 500, + duration: 500 }, backgroundColor: 'red', datasets: { line: { animation: { - duration: 600, + duration: 600 }, backgroundColor: 'blue', - }, + } }, elements: { point: { - backgroundColor: 'red', - }, - }, - }, + backgroundColor: 'red' + } + } + } }); const doughnutOptions: DoughnutControllerChartOptions = {