Skip to content

Commit e307756

Browse files
authored
Fixes #559 (#560)
1 parent 1d765ae commit e307756

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

docs/guide/configuration.md

Lines changed: 38 additions & 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
| `clip` | `boolean` | No | `true` | Are the annotations clipped to the chartArea.
1212
| `drawTime` | `string` | Yes | `'afterDatasetsDraw'` | See [drawTime](options#draw-time)
1313
| `dblClickSpeed` | `number` | Yes | `350` | Time to detect a double click in ms.
14+
| [`animations`](#animations) | `object` | No | [see here](#default-animations) | To configure which element properties are animated and how
1415

1516
:::warning
1617

@@ -20,7 +21,43 @@ Nevertheless events are only catched over the chartArea.
2021

2122
:::
2223

23-
### Events
24+
## Animations
25+
26+
Animations options configures which element properties are animated and how, with the same configuration of [chart.js](https://www.chartjs.org/docs/latest/configuration/animations.html#animations-2).
27+
28+
```javascript
29+
const options = {
30+
plugins: {
31+
annotation: {
32+
animations: {
33+
numbers: {
34+
properties: ['x', 'y', 'x2', 'y2', 'width', 'height', 'radius'],
35+
type: 'number'
36+
},
37+
},
38+
annotations: {
39+
box1: {
40+
type: 'box',
41+
xMin: 1,
42+
xMax: 2,
43+
yMin: 50,
44+
yMax: 70,
45+
backgroundColor: 'rgba(255, 99, 132, 0.5)'
46+
}
47+
}
48+
}
49+
}
50+
};
51+
```
52+
53+
### Default animations
54+
55+
| Name | Option | Value
56+
| ---- | ---- | ----
57+
| `numbers` | `properties` | `['x', 'y', 'x2', 'y2', 'width', 'height', 'pointX', 'pointY', 'labelX', 'labelY', 'labelWidth', 'labelHeight', 'radius']`
58+
| `numbers` | `type` | `number`
59+
60+
## Events
2461

2562
The following options are available for all annotation types. These options can be specified per annotation, or at the top level which apply to all annotations.
2663

types/options.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@ export interface AnnotationPluginOptions extends AnnotationEvents {
133133
clip?: boolean,
134134
dblClickSpeed?: Scriptable<number, PartialEventContext>,
135135
drawTime?: Scriptable<DrawTime, PartialEventContext>,
136-
animations: Record<string, unknown>,
136+
animations?: Record<string, unknown>,
137137
}

0 commit comments

Comments
 (0)