You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/configuration/animations.mdx
+47-31Lines changed: 47 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,10 +107,28 @@ function example() {
107
107
</TabItem>
108
108
</Tabs>
109
109
110
-
## Animation Configuration
110
+
## Animation configuration
111
111
112
-
The following animation options are available. The global options are defined in `Chart.defaults.animation`.
113
-
The default configuration is defined here: <ahref="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L6-L55"target="_blank">core.animations.js</a>
*`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: <ahref="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L9-L56"target="_blank">core.animations.js</a>
114
132
115
133
| Name | Type | Default | Description
116
134
| ---- | ---- | ------- | -----------
@@ -119,32 +137,13 @@ The default configuration is defined here: <a href="https://github.com/chartjs/C
119
137
| `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart.
120
138
| `delay` | `number` | `undefined` | Delay before starting the animations.
121
139
| `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.
124
140
125
141
These defaults can be overridden in `options.animation` or `dataset.animation` and `tooltip.animation`. These keys are also [Scriptable](../general/options.md#scriptable-options).
126
142
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
145
144
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:
148
147
149
148
| Name | Type | Default | Description
150
149
| ---- | ---- | ------- | -----------
@@ -154,7 +153,7 @@ A property option is defined by the same options of the main [animation configur
154
153
| `to` | `number`\|`Color`\|`boolean` | `undefined` | End value for the animation. Updated value is used when `undefined`
155
154
|`fn`| <code><T>(from: T, to: T, factor: number) => T;</code> |`undefined`| Optional custom interpolator, instead of using a predefined interpolator from `type`|
156
155
157
-
### Default properties
156
+
### Default animations
158
157
159
158
| Name | Option | Value
160
159
| ---- | ------ | -----
@@ -164,18 +163,35 @@ A property option is defined by the same options of the main [animation configur
164
163
| `colors` | `type` | `'color'`
165
164
166
165
:::note
167
-
These default collections are overridden by most dataset controllers.
166
+
These default animations are overridden by most of the dataset controllers.
168
167
:::
169
168
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
+
170
186
## Disabling animation
171
187
172
188
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`.
173
189
174
190
```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
0 commit comments