use*_*058 3 html javascript jquery
最近我的html人使用jquery插件-in名称实现了piechart,就像easyPieChart一样,就像以下方式一样.

HTML代码:
<span class="chart pull-right" data-percent="45" id="_percentUpdate">
<div class="flip-container">
<div class="flipper" onclick="this.classList.toggle('flipped')" id="conserHoursFlip">
<div class="front percent"></div>
<div class="back percent"></div>
</div>
</div>
<span>
Run Code Online (Sandbox Code Playgroud)
我想通过JavaScript或backbone.js动态更改条形颜色,但我无法修复此问题.
现在它是green彩色的,我想换成另一种颜色.
谁能帮我.
谢谢.
Ili*_*sev 13
花了我一些时间弄清楚是如何让它根据百分比动态显示所需的颜色.这就是我在jQuery中提出的:
$('.piechart').easyPieChart({
barColor: function (percent) {
return (percent < 50 ? '#5cb85c' : percent < 85 ? '#f0ad4e' : '#cb3935');
},
size: 150,
scaleLength: 7,
trackWidth: 5,
lineWidth: 5,
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
Run Code Online (Sandbox Code Playgroud)
这是一个例子,说明如果您有多个Chart Pie,它会是什么样子:

小智 5
我一直试图自己解决这个问题,经过一番愚弄,这似乎对我有用.
$('#your_chart').data('easyPieChart').options.barColor = '#0033CC';
Run Code Online (Sandbox Code Playgroud)