Skip to content

Move interaction object at top level of plugin options #736

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

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following options are available at the top level. They apply to all annotati
| [`animations`](#animations) | `object` | No | [see here](#default-animations) | To configure which element properties are animated and how.
| `clip` | `boolean` | No | `true` | Are the annotations clipped to the chartArea.
| [`common`](#common) | `Object` | No | | To configure common options apply to all annotations
| [`interaction`](options#interaction) | `Object` | No | `options.interaction` | To configure which events trigger plugin interactions

:::warning

Expand Down Expand Up @@ -63,7 +64,6 @@ The following options apply to all annotations unless they are overwritten on a
| Name | Type | [Scriptable](options#scriptable-options) | Default | Notes
| ---- | ---- | :----: | ---- | ----
| `drawTime` | `string` | Yes | `'afterDatasetsDraw'` | See [drawTime](options#draw-time).
| [`interaction`](options#interaction) | `Object` | No | `options.interaction` | To configure which events trigger plugin interactions

## Events

Expand Down
16 changes: 8 additions & 8 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ export default {
},
},
clip: true,
interaction: {
mode: undefined,
axis: undefined,
intersect: undefined
},
common: {
drawTime: 'afterDatasetsDraw',
interaction: {
mode: undefined,
axis: undefined,
intersect: undefined
},
label: {
}
}
Expand All @@ -127,10 +127,10 @@ export default {
_allKeys: false,
_fallback: (prop, opts) => `elements.${annotationTypes[resolveType(opts.type)].id}`
},
interaction: {
_fallback: true
},
common: {
interaction: {
_fallback: true
},
label: {
_fallback: true
}
Expand Down
6 changes: 3 additions & 3 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ interface PolygonAnnotationOptions extends CoreAnnotationOptions, AnnotationPoin
}

export interface AnnotationPluginCommonOptions {
drawTime?: Scriptable<DrawTime, PartialEventContext>,
interaction?: CoreInteractionOptions
drawTime?: Scriptable<DrawTime, PartialEventContext>
}

export interface AnnotationPluginOptions extends AnnotationEvents {
animations?: Record<string, unknown>,
annotations: AnnotationOptions[] | Record<string, AnnotationOptions>,
clip?: boolean,
common?: AnnotationPluginCommonOptions
common?: AnnotationPluginCommonOptions,
interaction?: CoreInteractionOptions
}
11 changes: 6 additions & 5 deletions types/tests/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const chart = new Chart('id', {
plugins: {
annotation: {
clip: false,
interaction: {
mode: 'nearest',
axis: 'xy',
intersect: true
},
common: {
interaction: {
mode: 'nearest',
axis: 'xy',
intersect: true
}
drawTime: 'afterDraw'
},
annotations: [{
type: 'line',
Expand Down