Skip to content

Commit 4cf1a3d

Browse files
committed
Fix and further consolidate init types
1 parent 21e53fc commit 4cf1a3d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

types/options.d.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ interface ShadowOptions {
3535
shadowOffsetY?: Scriptable<number, PartialEventContext>
3636
}
3737

38+
export interface InitContext {
39+
chart: Chart,
40+
properties: AnnotationBoxModel,
41+
options: AnnotationOptions
42+
}
43+
44+
export type ScriptableInit = boolean | ((ctx: InitContext) => void | boolean | Partial<AnnotationElement>);
45+
3846
export interface CoreAnnotationOptions extends AnnotationEvents, ShadowOptions, AnnotationHooks {
3947
adjustScaleRange?: Scriptable<boolean, PartialEventContext>,
4048
borderColor?: Scriptable<Color, PartialEventContext>,
@@ -44,7 +52,7 @@ export interface CoreAnnotationOptions extends AnnotationEvents, ShadowOptions,
4452
display?: Scriptable<boolean, PartialEventContext>,
4553
drawTime?: Scriptable<DrawTime, PartialEventContext>,
4654
hitTolerance?: Scriptable<number, PartialEventContext>,
47-
init?: boolean | (({ chart: Chart, properties: AnnotationBoxModel, options: AnnotationOptions }) => void | boolean | Partial<AnnotationElement>),
55+
init?: ScriptableInit,
4856
id?: string,
4957
xMax?: Scriptable<ScaleValue, PartialEventContext>,
5058
xMin?: Scriptable<ScaleValue, PartialEventContext>,
@@ -138,17 +146,11 @@ export interface LabelAnnotationOptions extends CoreAnnotationOptions, LabelType
138146
rotation?: Scriptable<number, PartialEventContext>
139147
}
140148

141-
interface InitContext {
142-
chart: Chart,
143-
properties: AnnotationBoxModel,
144-
options: AnnotationOptions
145-
}
146-
147149
export interface DoughnutLabelAnnotationOptions extends AnnotationEvents, DoughnutLabelOptions, ShadowOptions {
148150
autoFit?: Scriptable<boolean, PartialEventContext>,
149151
autoHide?: Scriptable<boolean, PartialEventContext>,
150152
id?: string,
151-
init: boolean | ((ctx: InitContext) => void | boolean | AnnotationElement),
153+
init?: ScriptableInit,
152154
spacing?: Scriptable<number, PartialEventContext>
153155
}
154156

0 commit comments

Comments
 (0)