From 0c60df4fe19f9e5e3c1b49362ee93b8a3d8fc1ea Mon Sep 17 00:00:00 2001 From: stockiNail Date: Mon, 16 May 2022 13:45:29 +0200 Subject: [PATCH] Move interaction object out of common one in plugin options --- docs/guide/configuration.md | 2 +- src/annotation.js | 16 ++++++++-------- types/options.d.ts | 6 +++--- types/tests/exports.ts | 11 ++++++----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index f92047a2a..7ef439717 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -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 @@ -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 diff --git a/src/annotation.js b/src/annotation.js index db8e1eb60..37b619333 100644 --- a/src/annotation.js +++ b/src/annotation.js @@ -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: { } } @@ -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 } diff --git a/types/options.d.ts b/types/options.d.ts index fe0b7b4a9..a3fffaf57 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -152,13 +152,13 @@ interface PolygonAnnotationOptions extends CoreAnnotationOptions, AnnotationPoin } export interface AnnotationPluginCommonOptions { - drawTime?: Scriptable, - interaction?: CoreInteractionOptions + drawTime?: Scriptable } export interface AnnotationPluginOptions extends AnnotationEvents { animations?: Record, annotations: AnnotationOptions[] | Record, clip?: boolean, - common?: AnnotationPluginCommonOptions + common?: AnnotationPluginCommonOptions, + interaction?: CoreInteractionOptions } diff --git a/types/tests/exports.ts b/types/tests/exports.ts index 373e975dc..d146524f0 100644 --- a/types/tests/exports.ts +++ b/types/tests/exports.ts @@ -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',