I using easy pie chart library for visualisation.
I want to be able to count up with the same duration given in the easy pie chart animate key, everything works fine except the duration of the easy pie chart animate is faster than the duration of the loop counter value. How can I make the speed of both or the duration the same so they arrive at the same value?
html:
<div class="percentile">
<div class="percentile-value" data-percent="99">
<p class="circle"></p>
</div>
</div>
js:
$(function () {
$(".percentile-value").easyPieChart({
//your options goes here
size: 500,
lineWidth: 6,
barColor: "#055a82",
animate: {
duration: 5000,
enabled: true,
},
});
});
let counter = 99;
let circlePara = document.querySelector(".circle");
const slowLoop = (time) => {
return new Promise((resolve) => setTimeout(resolve, time));
};
const increaseCounter = async () => {
for (let i = 0; i <= counter; i++) {
await slowLoop(180);
circlePara.innerHTML = `${i}`;
}
};
increaseCounter();
Thank you in advance.