// progresscircle.js
(function($) {
$.fn.circlechart = function() {
this.each(function() {
var percentage = $(this).data("percentage");
var inner_text = $(this).text();
$(this).html(makesvg(percentage, inner_text));
});
return this;
};
// 添加的代码
$.fn.setChart = function(val) {
$(this).find('.circle-chart__circle').attr('stroke-dasharray', val + ',100').next().find('.circle-chart__percent').html(val + '%')
}
}(jQuery));
// 调用
$('.circlechart').circlechart(); // 初始化
setInterval(() => {
// 设置圆环
$('.circlechart').data('percentage', $('.circlechart').data('percentage') + 1)
// 设置文字百分比
$('.circlechart').setChart($('.circlechart').data('percentage') + 1);
}, 2000)