Skip to content

Commit ed84a72

Browse files
authored
Move interaction object out of common one in plugin options (#736)
1 parent daac19b commit ed84a72

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

docs/guide/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The following options are available at the top level. They apply to all annotati
1111
| [`animations`](#animations) | `object` | No | [see here](#default-animations) | To configure which element properties are animated and how.
1212
| `clip` | `boolean` | No | `true` | Are the annotations clipped to the chartArea.
1313
| [`common`](#common) | `Object` | No | | To configure common options apply to all annotations
14+
| [`interaction`](options#interaction) | `Object` | No | `options.interaction` | To configure which events trigger plugin interactions
1415

1516
:::warning
1617

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

6868
## Events
6969

src/annotation.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ export default {
108108
},
109109
},
110110
clip: true,
111+
interaction: {
112+
mode: undefined,
113+
axis: undefined,
114+
intersect: undefined
115+
},
111116
common: {
112117
drawTime: 'afterDatasetsDraw',
113-
interaction: {
114-
mode: undefined,
115-
axis: undefined,
116-
intersect: undefined
117-
},
118118
label: {
119119
}
120120
}
@@ -127,10 +127,10 @@ export default {
127127
_allKeys: false,
128128
_fallback: (prop, opts) => `elements.${annotationTypes[resolveType(opts.type)].id}`
129129
},
130+
interaction: {
131+
_fallback: true
132+
},
130133
common: {
131-
interaction: {
132-
_fallback: true
133-
},
134134
label: {
135135
_fallback: true
136136
}

types/options.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ interface PolygonAnnotationOptions extends CoreAnnotationOptions, AnnotationPoin
153153
}
154154

155155
export interface AnnotationPluginCommonOptions {
156-
drawTime?: Scriptable<DrawTime, PartialEventContext>,
157-
interaction?: CoreInteractionOptions
156+
drawTime?: Scriptable<DrawTime, PartialEventContext>
158157
}
159158

160159
export interface AnnotationPluginOptions extends AnnotationEvents {
161160
animations?: Record<string, unknown>,
162161
annotations: AnnotationOptions[] | Record<string, AnnotationOptions>,
163162
clip?: boolean,
164-
common?: AnnotationPluginCommonOptions
163+
common?: AnnotationPluginCommonOptions,
164+
interaction?: CoreInteractionOptions
165165
}

types/tests/exports.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ const chart = new Chart('id', {
1616
plugins: {
1717
annotation: {
1818
clip: false,
19+
interaction: {
20+
mode: 'nearest',
21+
axis: 'xy',
22+
intersect: true
23+
},
1924
common: {
20-
interaction: {
21-
mode: 'nearest',
22-
axis: 'xy',
23-
intersect: true
24-
}
25+
drawTime: 'afterDraw'
2526
},
2627
annotations: [{
2728
type: 'line',

0 commit comments

Comments
 (0)