]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
chore: #10963 revert (#11102)
authorDan Onoshko <danon0404@gmail.com>
Tue, 7 Feb 2023 16:51:48 +0000 (23:51 +0700)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2023 16:51:48 +0000 (11:51 -0500)
src/types/index.d.ts
test/types/config_types.ts [deleted file]

index 9dbf5b1debf9140a143e1a663b0f2eff0e715987..b6f90af8bc7c78ef6549d3121451c17cc652e21c 100644 (file)
@@ -492,7 +492,7 @@ export declare class Chart<
   readonly id: string;
   readonly canvas: HTMLCanvasElement;
   readonly ctx: CanvasRenderingContext2D;
-  readonly config: ChartConfigurationInstance;
+  readonly config: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>;
   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<TType>; // Only available if legend plugin is registered and enabled
+  readonly tooltip?: TooltipModel<TType>; // Only available if tooltip plugin is registered and enabled
 
-  data: ChartData;
-  options: ChartOptions;
+  data: ChartData<TType, TData, TLabel>;
+  options: ChartOptions<TType>;
 
   constructor(item: ChartItem, config: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>);
 
@@ -2197,7 +2197,7 @@ export interface LegendItem {
   textAlign?: TextAlign;
 }
 
-export interface LegendElement<TType extends ChartType = ChartType> extends Element<AnyObject, LegendOptions<TType>>, LayoutItem {
+export interface LegendElement<TType extends ChartType> extends Element<AnyObject, LegendOptions<TType>>, LayoutItem {
   chart: Chart<TType>;
   ctx: CanvasRenderingContext2D;
   legendItems?: LegendItem[];
@@ -2431,7 +2431,7 @@ export interface TooltipLabelStyle {
    */
   borderRadius?: number | BorderRadius;
 }
-export interface TooltipModel<TType extends ChartType = ChartType> extends Element<AnyObject, TooltipOptions<TType>> {
+export interface TooltipModel<TType extends ChartType> extends Element<AnyObject, TooltipOptions<TType>> {
   readonly chart: Chart<TType>;
 
   // The items that we are rendering in the tooltip. See Tooltip Item Interface section
@@ -3676,5 +3676,3 @@ export interface ChartConfigurationCustomTypesPerDataset<
   options?: ChartOptions<TType>;
   plugins?: Plugin<TType>[];
 }
-
-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 (file)
index e636919..0000000
+++ /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]
-});