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
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>
113
-
Namespace: `options.animation`, the global options are defined in `Chart.defaults.animation`.
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: <ahref="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L9-L56"target="_blank">core.animations.js</a>
132
+
133
+
Namespace: `options.animation`
114
134
115
135
| Name | Type | Default | Description
116
136
| ---- | ---- | ------- | -----------
@@ -119,84 +139,65 @@ Namespace: `options.animation`, the global options are defined in `Chart.defaul
119
139
| `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart.
120
140
| `delay` | `number` | `undefined` | Delay before starting the animations.
121
141
| `loop` | `boolean` | `undefined` | If set to `true`, the animations loop endlessly.
122
-
| [[mode]](#animation-mode-configuration) | `object` | [defaults...](#default-modes) | Option overrides for update mode. Core modes: `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. See **Hide and show [mode]** example above.
123
-
| [[property]](#animation-property-configuration) | `object` | `undefined` | Option overrides for a single element `[property]`. These have precedence over `[collection]`. See **Looping tension [property]** example above.
124
-
| [[collection]](#animation-properties-collection-configuration) | `object` | [defaults...](#default-collections) | Option overrides for multiple properties, identified by `properties` array.
125
142
126
143
These defaults can be overridden in `options.animation` or `dataset.animation` and `tooltip.animation`. These keys are also [Scriptable](../general/options.md#scriptable-options).
127
144
128
-
## Animation mode configuration
145
+
## animations
129
146
130
-
Mode option configures how an update mode animates the chart.
131
-
The cores modes are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
132
-
A custom mode can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
133
-
A mode option is defined by the same options of the main [animation configuration](#animation-configuration).
147
+
Animations options configures which element properties are animated and how.
148
+
In addition to the main [animation configuration](#animation-configuration), the following options are available:
134
149
135
-
### Default modes
136
-
137
-
Namespace: `options.animation`
138
-
139
-
| Mode | Option | Value | Description
140
-
| -----| ------ | ----- | -----
141
-
| `active` | duration | 400 | Override default duration to 400ms for hover animations
142
-
| `resize` | duration | 0 | Override default duration to 0ms (= no animation) for resize
143
-
| `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).
144
-
| `show` | visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
145
-
| `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).
146
-
| `hide` | visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
147
-
148
-
## Animation property configuration
149
-
150
-
Property option configures which element property to use to animate the chart and its starting and ending values.
151
-
A property option is defined by the same options of the main [animation configuration](#animation-configuration), adding the following ones:
152
-
153
-
Namespace: `options.animation[animation]`
150
+
Namespace: `options.animations[animation]`
154
151
155
152
| Name | Type | Default | Description
156
153
| ---- | ---- | ------- | -----------
154
+
| `properties` | `string[]` | `key` | The property names this configuration applies to. Defaults to the key name of this object.
157
155
| `type` | `string` | `typeof property` | Type of property, determines the interpolator used. Possible values: `'number'`, `'color'` and `'boolean'`. Only really needed for `'color'`, because `typeof` does not get that right.
158
156
| `from` | `number`\|`Color`\|`boolean` | `undefined` | Start value for the animation. Current value is used when `undefined`
159
157
| `to` | `number`\|`Color`\|`boolean` | `undefined` | End value for the animation. Updated value is used when `undefined`
160
158
|`fn`| <code><T>(from: T, to: T, factor: number) => T;</code> |`undefined`| Optional custom interpolator, instead of using a predefined interpolator from `type`|
161
159
162
-
## Animation properties collection configuration
163
-
164
-
Properties collection option configures which set of element properties to use to animate the chart.
165
-
Collection can be named whatever you like, but should not collide with a `[property]` or `[mode]`.
166
-
A properties collection option is defined by the same options as the [animation property configuration](#animation-property-configuration), adding the following one:
167
-
168
-
The animation properties collection configuration can be adjusted in the `options.animation[collection]` namespace.
169
-
170
-
| Name | Type | Default | Description
171
-
| ---- | ---- | ------- | -----------
172
-
| `properties` | `string[]` | `undefined` | Set of properties to use to animate the chart.
Direct property configuration overrides configuration of same property in a collection.
184
-
185
-
From collections, a property gets its configuration from first one that has its name in properties.
186
168
187
169
:::note
188
-
These default collections are overridden by most dataset controllers.
170
+
These default animations are overridden by most of the dataset controllers.
189
171
:::
190
172
173
+
## transitions
174
+
175
+
The core transitions are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
176
+
A custom transtion can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
177
+
Transition extends the main [animation configuration](#animation-configuration) and [animations configuration](#animations-configuration).
178
+
179
+
### Default transitions
180
+
181
+
Namespace: `options.transitions[mode]`
182
+
183
+
| Mode | Option | Value | Description
184
+
| -----| ------ | ----- | -----
185
+
| `'active'` | animation.duration | 400 | Override default duration to 400ms for hover animations
186
+
| `'resize'` | animation.duration | 0 | Override default duration to 0ms (= no animation) for resize
187
+
| `'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).
188
+
| `'show'` | animations.visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
189
+
| `'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).
190
+
| `'hide'` | animations.visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
191
+
191
192
## Disabling animation
192
193
193
194
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`.
194
195
195
196
```javascript
196
-
chart.options.animation=false; // disables the whole animation
197
-
chart.options.animation.active.duration=0; // disables the animation for 'active' mode
198
-
chart.options.animation.colors=false; // disables animation defined by the collection of 'colors' properties
199
-
chart.options.animation.x=false; // disables animation defined by the 'x' property
197
+
chart.options.animation=false; // disables all animations
198
+
chart.options.animations.colors=false; // disables animation defined by the collection of 'colors' properties
199
+
chart.options.animations.x=false; // disables animation defined by the 'x' property
200
+
chart.options.transitions.active.animation.duration=0; // disables the animation for 'active' mode
Copy file name to clipboardExpand all lines: docs/docs/developers/api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's v
28
28
myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
29
29
```
30
30
31
-
A `mode` string can be provided to indicate what should be updated and what animation configuration should be used. Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also a supported mode for skipping animations for single update. Please see [animations](../configuration/animations.mdx) docs for more details.
31
+
A `mode` string can be provided to indicate transition configuration should be used. Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also a supported mode for skipping animations for single update. Please see [animations](../configuration/animations.mdx) docs for more details.
0 commit comments