Skip to content

Fix types for scriptable init #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ interface ShadowOptions {
shadowOffsetY?: Scriptable<number, PartialEventContext>
}

export interface InitContext {
chart: Chart,
properties: AnnotationBoxModel,
options: AnnotationOptions
}

export type ScriptableInit = boolean | ((ctx: InitContext) => void | boolean | Partial<AnnotationElement>);

export interface CoreAnnotationOptions extends AnnotationEvents, ShadowOptions, AnnotationHooks {
adjustScaleRange?: Scriptable<boolean, PartialEventContext>,
borderColor?: Scriptable<Color, PartialEventContext>,
Expand All @@ -44,7 +52,7 @@ export interface CoreAnnotationOptions extends AnnotationEvents, ShadowOptions,
display?: Scriptable<boolean, PartialEventContext>,
drawTime?: Scriptable<DrawTime, PartialEventContext>,
hitTolerance?: Scriptable<number, PartialEventContext>,
init?: boolean | (({ chart: Chart, properties: AnnotationBoxModel, options: AnnotationOptions }) => void | boolean | Partial<AnnotationElement>),
init?: ScriptableInit,
id?: string,
xMax?: Scriptable<ScaleValue, PartialEventContext>,
xMin?: Scriptable<ScaleValue, PartialEventContext>,
Expand Down Expand Up @@ -142,7 +150,7 @@ export interface DoughnutLabelAnnotationOptions extends AnnotationEvents, Doughn
autoFit?: Scriptable<boolean, PartialEventContext>,
autoHide?: Scriptable<boolean, PartialEventContext>,
id?: string,
init: boolean | ((chart: Chart, properties: AnnotationBoxModel, options: AnnotationOptions) => void | boolean | AnnotationBoxModel),
init?: ScriptableInit,
spacing?: Scriptable<number, PartialEventContext>
}

Expand Down
Loading