直接上代码 先要设置 动画时长 然后用定时函数 调用clear函数 在从新绘制图表
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar',
animationDuration: 5000,
// animationDurationUpdate: 750,
animationEasing: 'linear'
}
]
};
setInterval(() => {
myChart.clear();
myChart.setOption(option);
}, 5200);