我正在使用 jQuery easy pie chart plugin用于制作饼图。最初我传递默认配置参数。之后,我想更改饼图的 bar-color
、size
等配置参数。
默认配置参数:
$('.chart').easyPieChart({
easing: 'easeOutCirc',
barColor: '#1abc9c ',
trackColor: '#f9f9f9 ',
scaleColor:false,
scaleLength: 5,
percent: 67,
lineCap: 'round',
lineWidth: 15, //12
size: 150, //110
animate: {duration: 2000, enabled: true},
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
我知道如何动态设置饼图的percentage
值,就像下面这样:
$('#'+domId).data('easyPieChart').update(value);
除了percentage
,我想像这样动态设置配置参数:
我想动态设置饼图的size
、bar-color
。为此,我尝试了很多方法,但没有找到正确的方法。
为此,我制作了JSFIddle用于理解。初始大小应为 110
单击 redraw
按钮后需要更改 饼图
的大小。但它不起作用。
告诉我,我使用的插件是否满足我的要求?如果是这样,我该如何解决?
最佳答案
我们必须销毁现有数据,然后重新创建图表
var $chart = $(".easy-pie-chart");
$chart.data('easy-pie-chart', null);
$chart.easyPieChart({
// my new settings here
});
关于javascript - 如何更改 jQuery "easy pie chart"插件的配置参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21906336/