Skip to content

Commit a391040

Browse files
committed
Update docs
1 parent b069274 commit a391040

File tree

1 file changed

+47
-31
lines changed

1 file changed

+47
-31
lines changed

docs/docs/configuration/animations.mdx

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,28 @@ function example() {
107107
</TabItem>
108108
</Tabs>
109109

110-
## Animation Configuration
110+
## Animation configuration
111111

112-
The following animation options are available. The global options are defined in `Chart.defaults.animation`.
113-
The default configuration is defined here: <a href="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L6-L55" target="_blank">core.animations.js</a>
112+
Animation configuration consists of 3 keys.
113+
114+
| Name | Type | Details
115+
| ---- | ---- | -------
116+
| animation | `object` | [animation](#animation)
117+
| animations | `object` | [animations](#animations)
118+
| transitions | `object` | [transitions](#transitions)
119+
120+
These keys can be configured in following paths:
121+
122+
* `` - chart options
123+
* `controllers[type]` - controller type options
124+
* `controllers[type].datasets` - dataset type options
125+
* `datasets[type]` - dataset type options
126+
127+
These paths are valid under `defaults` for global confuguration and `options` for instance configuration.
128+
129+
## animation
130+
131+
The default configuration is defined here: <a href="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L9-L56" target="_blank">core.animations.js</a>
114132

115133
| Name | Type | Default | Description
116134
| ---- | ---- | ------- | -----------
@@ -119,32 +137,13 @@ The default configuration is defined here: <a href="https://github.com/chartjs/C
119137
| `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart.
120138
| `delay` | `number` | `undefined` | Delay before starting the animations.
121139
| `loop` | `boolean` | `undefined` | If set to `true`, the animations loop endlessly.
122-
| `modes` | `object` | [defaults...](#default-modes) | Option overrides for update modes. Core modes: `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. See **Hide and show [mode]** example above.
123-
| `properties` | `object` | [defaults...](#default-properties) | Option overrides for properties, identified by `properties` array which defaults to the key.
124140

125141
These defaults can be overridden in `options.animation` or `dataset.animation` and `tooltip.animation`. These keys are also [Scriptable](../general/options.md#scriptable-options).
126142

127-
## Transition configuration
128-
129-
The core transitions are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
130-
A custom transtion can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
131-
Transition consists from the same animation options of the main [animation configuration](#animation-configuration).
132-
133-
### Default transitions
134-
135-
| Mode | Option | Value | Description
136-
| -----| ------ | ----- | -----
137-
| `'active'` | duration | 400 | Override default duration to 400ms for hover animations
138-
| `'resize'` | duration | 0 | Override default duration to 0ms (= no animation) for resize
139-
| `'show'` | colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], from: 'transparent' }` | Colors are faded in from transparent when dataset is shown using legend / [api](../developers/api.md#showdatasetIndex).
140-
| `'show'` | visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
141-
| `'hide'` | colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], to: 'transparent' }` | Colors are faded to transparent when dataset id hidden using legend / [api](../developers/api.md#hidedatasetIndex).
142-
| `'hide'` | visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
143-
144-
## Animation properties configuration
143+
## animations
145144

146-
Property option configures which element property to use to animate the chart and its starting and ending values.
147-
A property option is defined by the same options of the main [animation configuration](#animation-configuration), adding the following ones:
145+
Animations options configures which element properties are animated and how.
146+
In addition to the main [animation configuration](#animation-configuration), the following options are available:
148147

149148
| Name | Type | Default | Description
150149
| ---- | ---- | ------- | -----------
@@ -154,7 +153,7 @@ A property option is defined by the same options of the main [animation configur
154153
| `to` | `number`\|`Color`\|`boolean` | `undefined` | End value for the animation. Updated value is used when `undefined`
155154
| `fn` | <code>&lt;T&gt;(from: T, to: T, factor: number) => T;</code> | `undefined` | Optional custom interpolator, instead of using a predefined interpolator from `type` |
156155

157-
### Default properties
156+
### Default animations
158157

159158
| Name | Option | Value
160159
| ---- | ------ | -----
@@ -164,18 +163,35 @@ A property option is defined by the same options of the main [animation configur
164163
| `colors` | `type` | `'color'`
165164

166165
:::note
167-
These default collections are overridden by most dataset controllers.
166+
These default animations are overridden by most of the dataset controllers.
168167
:::
169168

169+
## transitions
170+
171+
The core transitions are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
172+
A custom transtion can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
173+
Transition extends the main [animation configuration](#animation-configuration) and [animations configuration](#animations-configuration).
174+
175+
### Default transitions
176+
177+
| Mode | Option | Value | Description
178+
| -----| ------ | ----- | -----
179+
| `'active'` | animation.duration | 400 | Override default duration to 400ms for hover animations
180+
| `'resize'` | animation.duration | 0 | Override default duration to 0ms (= no animation) for resize
181+
| `'show'` | animations.colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], from: 'transparent' }` | Colors are faded in from transparent when dataset is shown using legend / [api](../developers/api.md#showdatasetIndex).
182+
| `'show'` | animations.visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
183+
| `'hide'` | animations.colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], to: 'transparent' }` | Colors are faded to transparent when dataset id hidden using legend / [api](../developers/api.md#hidedatasetIndex).
184+
| `'hide'` | animations.visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
185+
170186
## Disabling animation
171187

172188
To disable an animation configuration, the animation node must be set to `false`, with the exception for animation modes which can be disabled by setting the `duration` to `0`.
173189

174190
```javascript
175-
chart.options.animation = false; // disables the whole animation
176-
chart.options.animation.modes.active.duration = 0; // disables the animation for 'active' mode
177-
chart.options.animation.properties.colors = false; // disables animation defined by the collection of 'colors' properties
178-
chart.options.animation.properties.x = false; // disables animation defined by the 'x' property
191+
chart.options.animation = false; // disables all animations
192+
chart.options.animations.colors = false; // disables animation defined by the collection of 'colors' properties
193+
chart.options.animations.x = false; // disables animation defined by the 'x' property
194+
chart.options.transitions.active.animation.duration = 0; // disables the animation for 'active' mode
179195
```
180196

181197
## Easing

0 commit comments

Comments
 (0)