自定义动画
- 按需引用需要的动画执行函数。
- 帮助用户自定义动画执行函数。
// Step 1: 定义动画执行函数
function fadeIn(
shape: IShape | IGroup,
animateCfg: AnimateCfg,
cfg: AnimateExtraCfg,
) {
fillOpacity: isNil(shape.attr('fillOpacity'))
? 1
strokeOpacity: isNil(shape.attr('strokeOpacity'))
? 1
: shape.attr('strokeOpacity'),
opacity: isNil(shape.attr('opacity')) ? 1 : shape.attr('opacity'),
};
shape.attr({
fillOpacity: 0,
strokeOpacity: 0,
});
}
// Step 2: 注册动画执行函数
registerAnimation('fadeIn', fadeIn);
// Step 3: 使用
chart.interval().animate({
appear: {
animation: 'fadeIn',
API 链接。