Animate
The charts for mobile should be more vividness. So F2 provides an animation mechanism.
How to Register Animation Plugin
F2 has modular structure provides best tree-shaking results and package size optimization.
If you just import F2 from '@antv/f2'
, then it has included Animation
by default. But if you want a better package size optimization, you can register manually:
Animation Introduction
F2 animations are all animated in shapes. According to the change of the chart's data, we classified animation into four types in F2:
Type | Description | Trigger Timing |
appear | The entrance animation when the chart is first loaded. | first time calling |
enter | The entrance animation when the chart is re-rendered after the change of data. |
|
update | The update animation when the chart is re-rendered and the chart's shapes' status is updated after the change of the data. |
|
leave | The destroy animation when the chart's shapes are destroyed after the change of the data |
|
Methods
chart.animate(false)
chart.animate(false)
Close the chart's animation.
chart.<geomType>().animate(config)
chart.<geomType>().animate(config)
Animation configuration for geometry.
Parameters:
config
: Object / false.
If config
's value is false, means close the animation for the geometry.
If config
is an object, the properties can configure include:
Name | Type | Description |
| Object / Boolean | Configuration for appear animation. If |
| Object / Boolean | Configuration for enter animation. If |
| Object / Boolean | Configuration for update animation. If |
| Object / Boolean | Configuration for leave animation. If |
The configurable properties for appear
, enter
, update
and leave
are as follows:
Name | Type | Description |
| String / Function | |
| String / Function | easing action for animation.You can use the default easing functions provided by F2 or pass the function directly, see callback. |
| Number / Function | delay time for animation, in millisecond.You can specify delay time directly or pass a callback. |
| Number | duration of the animation, in millisecond. |
Example:
Default Animations
The animations provided by default are shown below:
Name | Demo | |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
animation
callback
animation
callbackAnimation action can also be a callback.
Default easing
easing
The default easing functions are:
linear
quadraticIn
quadraticOut
quadraticInOut
cubicIn
cubicOut
cubicInOut
elasticIn
elasticOut
elasticInOut
backIn
backOut
backInOut
bounceIn
bounceOut
bounceInOut
For animation effect of each easing function, see http://sole.github.io/tween.js/examples/03_graphs.html.
easing
callback
easing
callbackeasing
can also be a callback.
Example:
delay
callback
delay
callbackshape.animate()
shape.animate()
We also provide a method called animate
for Shape instance to act the specific animation. See below for usage:
Example
See demo here.
Last updated