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
Direct property configuration overrides configuration of same property in a collection.
33
+
34
+
These defaults can be overridden in `options.animation` and `dataset.animation`.
15
35
16
36
## Easing
17
37
18
38
Available options are:
39
+
19
40
*`'linear'`
20
41
*`'easeInQuad'`
21
42
*`'easeOutQuad'`
@@ -52,34 +73,23 @@ See [Robert Penner's easing equations](http://robertpenner.com/easing/).
52
73
53
74
## Animation Callbacks
54
75
55
-
The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed a `Chart.Animation` instance:
76
+
The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed following object:
56
77
57
78
```javascript
58
79
{
59
80
// Chart object
60
81
chart: Chart,
61
82
62
-
//Current Animation frame number
83
+
//Number of animations still in progress
63
84
currentStep: number,
64
85
65
-
//Number of animation frames
86
+
//Total number of animations at the start of current animation
66
87
numSteps: number,
67
-
68
-
// Animation easing to use
69
-
easing: string,
70
-
71
-
// Function that renders the chart
72
-
render:function,
73
-
74
-
// User callback
75
-
onAnimationProgress:function,
76
-
77
-
// User callback
78
-
onAnimationComplete:function
79
88
}
80
89
```
81
90
82
91
The following example fills a progress bar during the chart animation.
Copy file name to clipboardExpand all lines: docs/developers/api.md
+7-28Lines changed: 7 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,32 +17,23 @@ This must be called before the canvas is reused for a new chart.
17
17
myLineChart.destroy();
18
18
```
19
19
20
-
## .update(config)
20
+
## .update(mode)
21
21
22
22
Triggers an update of the chart. This can be safely called after updating the data object. This will update all scales, legends, and then re-render the chart.
23
23
24
24
```javascript
25
-
// duration is the time for the animation of the redraw in milliseconds
26
-
// lazy is a boolean. if true, the animation can be interrupted by other animations
27
25
myLineChart.data.datasets[0].data[2] =50; // Would update the first dataset's value of 'March' to be 50
28
26
myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
29
27
```
30
28
31
29
> **Note:** replacing the data reference (e.g. `myLineChart.data = {datasets: [...]}` only works starting **version 2.6**. Prior that, replacing the entire data object could be achieved with the following workaround: `myLineChart.config.data = {datasets: [...]}`.
32
30
33
-
A `config` object can be provided with additional configuration for the update process. This is useful when `update` is manually called inside an event handler and some different animation is desired.
34
-
35
-
The following properties are supported:
36
-
***duration** (number): Time for the animation of the redraw in milliseconds
37
-
***lazy** (boolean): If true, the animation can be interrupted by other animations
38
-
***easing** (string): The animation easing function. See [Animation Easing](../configuration/animations.md) for possible values.
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 `undefined`, `'reset'`, `'resize'` or `'active'`. `'none'` is also a supported mode for skipping animations for single update.
39
32
40
33
Example:
34
+
41
35
```javascript
42
-
myChart.update({
43
-
duration:800,
44
-
easing:'easeOutBounce'
45
-
});
36
+
myChart.update();
46
37
```
47
38
48
39
See [Updating Charts](updates.md) for more details.
@@ -55,25 +46,13 @@ Reset the chart to it's state before the initial animation. A new animation can
55
46
myLineChart.reset();
56
47
```
57
48
58
-
## .render(config)
49
+
## .render()
59
50
60
51
Triggers a redraw of all chart elements. Note, this does not update elements for new data. Use `.update()` in that case.
61
52
62
-
See `.update(config)` for more details on the config object.
63
-
64
-
```javascript
65
-
// duration is the time for the animation of the redraw in milliseconds
66
-
// lazy is a boolean. if true, the animation can be interrupted by other animations
67
-
myLineChart.render({
68
-
duration:800,
69
-
lazy:false,
70
-
easing:'easeOutBounce'
71
-
});
72
-
```
73
-
74
53
## .stop()
75
54
76
-
Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call `.render()` to re-animate.
55
+
Use this to stop any current animation. This will pause the chart during any current animation frame. Call `.render()` to re-animate.
77
56
78
57
```javascript
79
58
// Stops the charts animation loop at its current frame
@@ -175,5 +154,5 @@ Extensive examples of usage are available in the [Chart.js tests](https://github
Copy file name to clipboardExpand all lines: docs/developers/updates.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
@@ -97,4 +97,4 @@ Code sample for updating options can be found in [toggle-scale-type.html](../../
97
97
98
98
## Preventing Animations
99
99
100
-
Sometimes when a chart updates, you may not want an animation. To achieve this you can call `update` with a duration of `0`. This will render the chart synchronously and without an animation.
100
+
Sometimes when a chart updates, you may not want an animation. To achieve this you can call `update` with `'none'` as mode.
Copy file name to clipboardExpand all lines: docs/general/interactions/README.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,3 @@ The hover configuration is passed into the `options.hover` namespace. The global
7
7
| `mode` | `string` | `'nearest'` | Sets which elements appear in the tooltip. See [Interaction Modes](./modes.md#interaction-modes) for details.
8
8
| `intersect` | `boolean` | `true` | if true, the hover mode only applies when the mouse position intersects an item on the chart.
9
9
| `axis` | `string` | `'x'` | Can be set to `'x'`, `'y'`, or `'xy'` to define which directions are used in calculating distances. Defaults to `'x'` for `'index'` mode and `'xy'` in `dataset` and `'nearest'` modes.
10
-
| `animationDuration` | `number` | `400` | Duration in milliseconds it takes to animate hover style changes.
Copy file name to clipboardExpand all lines: docs/general/responsive.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@ Chart.js provides a [few options](#configuration-options) to enable responsivene
14
14
| Name | Type | Default | Description
15
15
| ---- | ---- | ------- | -----------
16
16
| `responsive` | `boolean` | `true` | Resizes the chart canvas when its container does ([important note...](#important-note)).
17
-
| `responsiveAnimationDuration` | `number` | `0` | Duration in milliseconds it takes to animate to new size after a resize event.
18
17
| `maintainAspectRatio` | `boolean` | `true` | Maintain the original canvas aspect ratio `(width / height)` when resizing.
19
18
| `aspectRatio` | `number` | `2` | Canvas aspect ratio (i.e. `width / height`, a value of 1 representing a square canvas). Note that this option is ignored if the height is explicitly defined either as attribute or via the style.
20
19
| `onResize` | `function` | `null` | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
Copy file name to clipboardExpand all lines: docs/getting-started/v3-migration.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,13 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released
49
49
*`scales.[x/y]Axes.time.max` was renamed to `scales[id].max`
50
50
*`scales.[x/y]Axes.time.min` was renamed to `scales[id].min`
51
51
52
+
### Animations
53
+
54
+
Animation system was completely rewritten in Chart.js v3. Each property can now be animated separately. Please see [animations](../configuration/animations.md) docs for details.
55
+
56
+
*`hover.animationDuration` is now configured in `animation.active.duration`
57
+
*`responsiveAnimationDuration` is now configured in `animation.resize.duration`
58
+
52
59
## Developer migration
53
60
54
61
### Removed
@@ -90,10 +97,8 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released
90
97
91
98
*`Chart.data.datasets[datasetIndex]._meta`
92
99
*`Element._ctx`
93
-
*`Element._model.datasetLabel`
94
-
*`Element._model.label`
95
-
*`Point._model.tension`
96
-
*`Point._model.steppedLine`
100
+
*`Element._model`
101
+
*`Element._view`
97
102
*`TimeScale._getPixelForOffset`
98
103
*`TimeScale.getLabelWidth`
99
104
@@ -108,7 +113,6 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released
108
113
*`helpers.log10` was renamed to `helpers.math.log10`
109
114
*`helpers.almostEquals` was renamed to `helpers.math.almostEquals`
110
115
*`helpers.almostWhole` was renamed to `helpers.math.almostWhole`
111
-
*`helpers._decimalPlaces` was renamed to `helpers.math._decimalPlaces`
112
116
*`helpers.distanceBetweenPoints` was renamed to `helpers.math.distanceBetweenPoints`
113
117
*`helpers.isNumber` was renamed to `helpers.math.isNumber`
114
118
*`helpers.sign` was renamed to `helpers.math.sign`
@@ -129,10 +133,12 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released
129
133
*`TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity`
130
134
*`TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction`
131
135
*`TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset`
136
+
*`Tooltip.options.legendColorBackgroupd` was renamed to `Tooltip.options.multiKeyBackground`
132
137
133
138
#### Renamed private APIs
134
139
135
140
*`helpers._alignPixel` was renamed to `helpers.canvas._alignPixel`
141
+
*`helpers._decimalPlaces` was renamed to `helpers.math._decimalPlaces`
0 commit comments