From 6cb10dc895aa97122f8306c91d6b7211e4af564e Mon Sep 17 00:00:00 2001 From: Dan Onoshko Date: Tue, 7 Feb 2023 23:51:48 +0700 Subject: [PATCH] chore: #10963 revert (#11102) --- src/types/index.d.ts | 16 ++++------ test/types/config_types.ts | 65 -------------------------------------- 2 files changed, 7 insertions(+), 74 deletions(-) delete mode 100644 test/types/config_types.ts diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 9dbf5b1debf..b6f90af8bc7 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -492,7 +492,7 @@ export declare class Chart< readonly id: string; readonly canvas: HTMLCanvasElement; readonly ctx: CanvasRenderingContext2D; - readonly config: ChartConfigurationInstance; + readonly config: ChartConfiguration | ChartConfigurationCustomTypesPerDataset; readonly width: number; readonly height: number; readonly aspectRatio: number; @@ -502,11 +502,11 @@ export declare class Chart< readonly scales: { [key: string]: Scale }; readonly attached: boolean; - readonly legend?: LegendElement; // Only available if legend plugin is registered and enabled - readonly tooltip?: TooltipModel; // Only available if tooltip plugin is registered and enabled + readonly legend?: LegendElement; // Only available if legend plugin is registered and enabled + readonly tooltip?: TooltipModel; // Only available if tooltip plugin is registered and enabled - data: ChartData; - options: ChartOptions; + data: ChartData; + options: ChartOptions; constructor(item: ChartItem, config: ChartConfiguration | ChartConfigurationCustomTypesPerDataset); @@ -2197,7 +2197,7 @@ export interface LegendItem { textAlign?: TextAlign; } -export interface LegendElement extends Element>, LayoutItem { +export interface LegendElement extends Element>, LayoutItem { chart: Chart; ctx: CanvasRenderingContext2D; legendItems?: LegendItem[]; @@ -2431,7 +2431,7 @@ export interface TooltipLabelStyle { */ borderRadius?: number | BorderRadius; } -export interface TooltipModel extends Element> { +export interface TooltipModel extends Element> { readonly chart: Chart; // The items that we are rendering in the tooltip. See Tooltip Item Interface section @@ -3676,5 +3676,3 @@ export interface ChartConfigurationCustomTypesPerDataset< options?: ChartOptions; plugins?: Plugin[]; } - -export type ChartConfigurationInstance = ChartConfiguration | ChartConfigurationCustomTypesPerDataset & { type?: undefined } diff --git a/test/types/config_types.ts b/test/types/config_types.ts deleted file mode 100644 index e63691952a9..00000000000 --- a/test/types/config_types.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Chart } from '../../src/types.js'; - -const chart = new Chart('chart', { - type: 'bar', - data: { - labels: ['1', '2', '3'], - datasets: [{ - data: [1, 2, 3] - }, - { - data: [1, 2, 3] - }], - } -}); - -chart.config.type = 'line'; - -const chart2 = new Chart('chart', { - type: 'bar', - data: { - labels: ['1', '2', '3'], - datasets: [{ - type: 'line', - data: [1, 2, 3] - }, - { - type: 'line', - data: [1, 2, 3] - }], - } -}); - -chart2.config.type = 'line'; - -const chart3 = new Chart('chart', { - data: { - labels: ['1', '2', '3'], - datasets: [{ - type: 'bar', - data: [1, 2, 3] - }, - { - type: 'bar', - data: [1, 2, 3], - categoryPercentage: 10 - }], - } -}); - -chart3.config.type = 'line'; - -const chart4 = new Chart('chart', { - data: { - labels: ['1', '2', '3'], - datasets: [{ - type: 'bar', - data: [1, 2, 3] - }] - } -}); - -chart4.data.datasets.push({ - type: 'line', - data: [1, 2, 3] -});