gpt4 book ai didi

javascript - Chartjs - onAnimationComplete 在动画实际完成之前触发

转载 作者:行者123 更新时间:2023-11-30 07:21:50 35 4
gpt4 key购买 nike

我的问题是 onAnimationComplete 事件在图表实际完成绘制之前触发。

我正在使用 ASP.NET MVC。

这是我的代码:

HTML:

<canvas id="scanedTodayChart" width="100" height="100"></canvas>

JS:

var scanedTodayChartCtx = document.getElementById("scanedTodayChart").getContext("2d");
var scanedTodayChart = new Chart(scanedTodayChartCtx, {
type: 'pie',

data: {
labels: [
"Red",
"White",
],
datasets: [
{
data: [10, 100],
backgroundColor: [
"#DA1A32",
"#F0FFFF"
],
borderWidth: false,
borderColor: false
}]
},
options: {
cutoutPercentage: 90,
},
borderColor: '#DA1A32',
fullWidth: true,
onAnimationComplete: new function () {
alert('onAnimationComplete')
}
});

最佳答案

我认为您没有定义动画。尝试 this exampleChart.js documentation 找到.

var scanedTodayChart = new Chart(scanedTodayChartCtx, {
type: 'pie',

data: {
labels: [
"Red",
"White",
],
datasets: [
{
data: [10, 100],
backgroundColor: [
"#DA1A32",
"#F0FFFF"
],
borderWidth: false,
borderColor: false
}]
},
options: {
cutoutPercentage: 90,
animation: {
duration: 2000,
onProgress: function(animation) {
$progress.attr({
value: animation.animationObject.currentStep / animation.animationObject.numSteps,
});
},
onComplete: function(animation) {
alert('onAnimationComplete')
}
}
},
borderColor: '#DA1A32',
fullWidth: true,
});

关于javascript - Chartjs - onAnimationComplete 在动画实际完成之前触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37730271/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com