[chart.js] Export plugin registration types (#33614)

* Export plugin registration types

Export the types `PluginServiceGlobalRegistration` and `PluginServiceRegistrationOptions` since they are publicly visible to the user.

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts
This commit is contained in:
Aviad Pineles
2019-03-11 22:01:49 +02:00
committed by Wesley Wigham
parent 9c114e3ed5
commit aca13d4ee5

View File

@@ -60,62 +60,8 @@ declare class Chart {
static Tooltip: Chart.ChartTooltipsStaticConfiguration;
}
declare class PluginServiceStatic {
register(plugin: PluginServiceGlobalRegistration & PluginServiceRegistrationOptions): void;
unregister(plugin: PluginServiceGlobalRegistration & PluginServiceRegistrationOptions): void;
}
interface PluginServiceGlobalRegistration {
id?: string;
}
interface PluginServiceRegistrationOptions {
beforeInit?(chartInstance: Chart, options?: any): void;
afterInit?(chartInstance: Chart, options?: any): void;
beforeUpdate?(chartInstance: Chart, options?: any): void;
afterUpdate?(chartInstance: Chart, options?: any): void;
beforeLayout?(chartInstance: Chart, options?: any): void;
afterLayout?(chartInstance: Chart, options?: any): void;
beforeDatasetsUpdate?(chartInstance: Chart, options?: any): void;
afterDatasetsUpdate?(chartInstance: Chart, options?: any): void;
beforeDatasetUpdate?(chartInstance: Chart, options?: any): void;
afterDatasetUpdate?(chartInstance: Chart, options?: any): void;
// This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw
// to do something on each animation frame
beforeRender?(chartInstance: Chart, options?: any): void;
afterRender?(chartInstance: Chart, options?: any): void;
// Easing is for animation
beforeDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDraw?(chartInstance: Chart, easing: string, options?: any): void;
// Before the datasets are drawn but after scales are drawn
beforeDatasetsDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDatasetsDraw?(chartInstance: Chart, easing: string, options?: any): void;
beforeDatasetDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDatasetDraw?(chartInstance: Chart, easing: string, options?: any): void;
// Called before drawing the `tooltip`. If any plugin returns `false`,
// the tooltip drawing is cancelled until another `render` is triggered.
beforeTooltipDraw?(chartInstance: Chart, tooltipData?: any, options?: any): void;
// Called after drawing the `tooltip`. Note that this hook will not,
// be called if the tooltip drawing has been previously cancelled.
afterTooltipDraw?(chartInstance: Chart, tooltipData?: any, options?: any): void;
// Called when an event occurs on the chart
beforeEvent?(chartInstance: Chart, event: Event, options?: any): void;
afterEvent?(chartInstance: Chart, event: Event, options?: any): void;
resize?(chartInstance: Chart, newChartSize: Chart.ChartSize, options?: any): void;
destroy?(chartInstance: Chart): void;
/** @deprecated since version 2.5.0. Use `afterLayout` instead. */
afterScaleUpdate?(chartInstance: Chart, options?: any): void;
register(plugin: Chart.PluginServiceGlobalRegistration & Chart.PluginServiceRegistrationOptions): void;
unregister(plugin: Chart.PluginServiceGlobalRegistration & Chart.PluginServiceRegistrationOptions): void;
}
interface Meta {
@@ -683,6 +629,60 @@ declare namespace Chart {
x: number;
y: number;
}
interface PluginServiceGlobalRegistration {
id?: string;
}
interface PluginServiceRegistrationOptions {
beforeInit?(chartInstance: Chart, options?: any): void;
afterInit?(chartInstance: Chart, options?: any): void;
beforeUpdate?(chartInstance: Chart, options?: any): void;
afterUpdate?(chartInstance: Chart, options?: any): void;
beforeLayout?(chartInstance: Chart, options?: any): void;
afterLayout?(chartInstance: Chart, options?: any): void;
beforeDatasetsUpdate?(chartInstance: Chart, options?: any): void;
afterDatasetsUpdate?(chartInstance: Chart, options?: any): void;
beforeDatasetUpdate?(chartInstance: Chart, options?: any): void;
afterDatasetUpdate?(chartInstance: Chart, options?: any): void;
// This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw
// to do something on each animation frame
beforeRender?(chartInstance: Chart, options?: any): void;
afterRender?(chartInstance: Chart, options?: any): void;
// Easing is for animation
beforeDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDraw?(chartInstance: Chart, easing: string, options?: any): void;
// Before the datasets are drawn but after scales are drawn
beforeDatasetsDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDatasetsDraw?(chartInstance: Chart, easing: string, options?: any): void;
beforeDatasetDraw?(chartInstance: Chart, easing: string, options?: any): void;
afterDatasetDraw?(chartInstance: Chart, easing: string, options?: any): void;
// Called before drawing the `tooltip`. If any plugin returns `false`,
// the tooltip drawing is cancelled until another `render` is triggered.
beforeTooltipDraw?(chartInstance: Chart, tooltipData?: any, options?: any): void;
// Called after drawing the `tooltip`. Note that this hook will not,
// be called if the tooltip drawing has been previously cancelled.
afterTooltipDraw?(chartInstance: Chart, tooltipData?: any, options?: any): void;
// Called when an event occurs on the chart
beforeEvent?(chartInstance: Chart, event: Event, options?: any): void;
afterEvent?(chartInstance: Chart, event: Event, options?: any): void;
resize?(chartInstance: Chart, newChartSize: ChartSize, options?: any): void;
destroy?(chartInstance: Chart): void;
/** @deprecated since version 2.5.0. Use `afterLayout` instead. */
afterScaleUpdate?(chartInstance: Chart, options?: any): void;
}
}
export = Chart;