[英]Chartjs Doughnut Chart smooth animation in countdown
我正在使用Chart.js中的甜甜圈图来显示60秒计时器图。
Gif: https : //imgur.com/UmhqzuO
options = {
tooltips: {enabled: false},
cutoutPercentage: 75,
animation: {duration: 1}
};
data = {
datasets: [
{
data: [this.percentage, 100 - this.percentage],
backgroundColor: [this.color, this.fillColor]
},
]
};
每秒钟,我都会更新图表以反映秒数。 计时器从60秒开始,并变为0。当前动画感觉像是在滴答作响。 我希望动画看起来像时钟一样平滑而不是滴答作响。
如何获得扫掠动画? 由于图表是在每秒之后重绘的,我如何保持最后一个位置并从该位置更新?
我使用了
const data = this.getDataSet();
this.doughnut.chart.data.datasets[0].backgroundColor = data.backgroundColor;
this.doughnut.chart.data.datasets[0].data = data.data;
this.doughnut.chart.update();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.