Skip to content

Commit d17293e

Browse files
authored
Add VisualElement extension to Flow element type definition (#73)
1 parent c6da94f commit d17293e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

types/index.esm.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import {
33
ChartComponent,
44
DatasetController,
55
Element,
6+
VisualElement,
67
FontSpec
78
} from 'chart.js';
9+
import { AnyObject } from 'chart.js/types/basic';
810

911
declare module 'chart.js' {
1012

@@ -78,36 +80,40 @@ declare module 'chart.js' {
7880
datasetOptions: SankeyControllerDatasetOptions;
7981
defaultDataPoint: SankeyDataPoint;
8082
parsedDataType: SankeyParsedData;
81-
metaExtensions:{}
83+
metaExtensions: AnyObject
8284
/* TODO: define sankey chart options */
83-
chartOptions: any;
85+
chartOptions: AnyObject;
8486
scales: keyof CartesianScaleTypeRegistry;
8587
};
8688
}
8789
}
8890

89-
type FlowOptions = {
91+
export interface FlowOptions {
9092
colorMode: 'gradient' | 'from' | 'to';
9193
colorFrom: string
9294
colorTo: string
9395
}
9496

95-
type FlowConfig = {
97+
export interface FlowConfig {
9698
x: number;
9799
y: number;
98100
x2: number;
99101
y2: number;
100102
height: number;
101103
options: FlowOptions
102-
};
104+
}
103105

104106
export type SankeyController = DatasetController
105107
export const SankeyController: ChartComponent & {
106108
prototype: SankeyController;
107109
new(chart: Chart, datasetIndex: number): SankeyController;
108110
};
109111

110-
export type Flow = Element<FlowConfig, FlowOptions>
112+
export interface Flow<
113+
T extends FlowConfig = FlowConfig,
114+
O extends FlowOptions = FlowOptions
115+
> extends Element<T, O>, VisualElement {}
116+
111117
export const Flow: ChartComponent & {
112118
prototype: Flow;
113119
new(cfg: FlowConfig): Flow;

0 commit comments

Comments
 (0)