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 chart.render()
enter
The entrance animation when the chart is re-rendered after the change of data.
chart.changeData(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.
chart.changeData(data)
leave
The destroy animation when the chart's shapes are destroyed after the change of the data
chart.changeData(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
appear
Object / Boolean
Configuration for appear animation. If appear
is false, means close the appear animation for the geometry.
enter
Object / Boolean
Configuration for enter animation. If enter
is false, means close the enter animation for the geometry.
update
Object / Boolean
Configuration for update animation. If update
is false, means close the update animation for the geometry.
leave
Object / Boolean
Configuration for leave animation. If leave
is false, means close the leave animation for the geometry.
The configurable properties for appear
, enter
, update
and leave
are as follows:
Name
Type
Description
animation
String / Function
easing
String / Function
delay
Number / Function
duration
Number
duration of the animation, in millisecond.
Example:
Default Animations
The animations provided by default are shown below:
Name
Demo
groupWaveIn
groupScaleInX
groupScaleInY
groupScaleInXY
shapesScaleInX
shapesScaleInY
shapesScaleInXY
fadeIn
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