diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 95358ecdd02..e8fa9b2b803 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -491,7 +491,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; @@ -501,11 +501,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); @@ -2196,7 +2196,7 @@ export interface LegendItem { textAlign?: TextAlign; } -export interface LegendElement extends Element>, LayoutItem { +export interface LegendElement extends Element>, LayoutItem { chart: Chart; ctx: CanvasRenderingContext2D; legendItems?: LegendItem[]; @@ -2430,7 +2430,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 @@ -3672,5 +3672,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] -});