]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Merge Chart instance with Chart factory (#7783)
authorxr0master <xr0master@gmail.com>
Sat, 12 Sep 2020 12:46:17 +0000 (15:46 +0300)
committerGitHub <noreply@github.com>
Sat, 12 Sep 2020 12:46:17 +0000 (08:46 -0400)
Co-authored-by: Sergey Khomushin <sergey@placer.io>
types/core/index.d.ts

index 483634438561879a7bbc90ea53ffa4432a6ad9c8..7eff0b2541e029800033b193481d7f1b1779a4cb 100644 (file)
@@ -232,7 +232,7 @@ export interface IParsingOptions {
     | false;
 }
 
-export interface Chart<TYPE extends IChartType = IChartType, DATA extends unknown[] = unknown[], LABEL = string> {
+export declare class Chart<TYPE extends IChartType = IChartType, DATA extends unknown[] = unknown[], LABEL = string> {
   readonly platform: BasePlatform;
   readonly id: string;
   readonly canvas: HTMLCanvasElement;
@@ -251,6 +251,8 @@ export interface Chart<TYPE extends IChartType = IChartType, DATA extends unknow
   data: IChartConfiguration<TYPE, DATA, LABEL>['data'];
   options: IChartConfiguration<TYPE, DATA, LABEL>['options'];
 
+  constructor(item: ChartItem, config: IChartConfiguration<TYPE, DATA, LABEL>);
+
   clear(): this;
   stop(): this;
 
@@ -284,6 +286,12 @@ export interface Chart<TYPE extends IChartType = IChartType, DATA extends unknow
   bindEvents(): void;
   unbindEvents(): void;
   updateHoverStyle(items: Element, mode: 'dataset', enabled: boolean): void;
+
+  static readonly version: string;
+  static readonly instances: { [key: string]: Chart };
+  static readonly registry: Registry;
+  static register(...items: IChartComponentLike[]): void;
+  static unregister(...items: IChartComponentLike[]): void;
 }
 
 export declare type ChartItem =
@@ -295,20 +303,6 @@ export declare type ChartItem =
   | { canvas: HTMLCanvasElement | OffscreenCanvas }
   | ArrayLike<CanvasRenderingContext2D | HTMLCanvasElement | OffscreenCanvas>;
 
-export const Chart: {
-  prototype: Chart;
-  new <TYPE extends IChartType = IChartType, DATA extends unknown[] = unknown[], LABEL = string>(
-    item: ChartItem,
-    config: IChartConfiguration<TYPE, DATA, LABEL>
-  ): Chart<TYPE, DATA, LABEL>;
-
-  readonly version: string;
-  readonly instances: { [key: string]: Chart };
-  readonly registry: Registry;
-  register(...items: IChartComponentLike[]): void;
-  unregister(...items: IChartComponentLike[]): void;
-};
-
 export enum UpdateModeEnum {
   resize = 'resize',
   reset = 'reset',