问题描述
我有一个使用JqPlot显示的饼图。我有兴趣改变切片的实际颜色,到目前为止还没有运气。
I have a pie chart displaying using JqPlot. I would be interested in changing the actual colors of the slice, and have had no luck so far.
我遇到了并尝试了解决方案,但我不确定我是否将它放在错误的地方(尝试将其插入代码中的几个位置)就像我在,饼图不再显示(实际上停止显示页面上的其余图表)。
I came across this link and tried the solution, but I'm not sure if I'm putting it in the wrong place (Have tried inserting it in a few locations in the code) as when I have it in, the pie chart no longer displays (and in fact stops the rest of the charts on the page from displaying).
以下是饼图的javascript代码:
Here is the javascript code for the pie chart:
$(document).ready(function () {
var data = [['US',33], ['IE',30], ['GB',23], ['AU',7], ['CA',4], ['RoW',7]];
var plot1 = jQuery.jqplot('Countries', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
sliceMargin: 5,
showDataLabels: true,
}
},
legend: { show: true, border: false, /*placement: 'outsideGrid', location: 'w'*/location: 'e', border: 'none' },
grid: {borderWidth:0, shadow:false, background: '#FFFFFF'}
}
);
});
有没有人有任何想法?
推荐答案
您可以将 seriesColors
应用于选项
对象,例如:
You can apply seriesColors
to an options
object eg:
options =
{
seriesColors: [ "#4bb2c5", "#c5b47f", "#EAA228", "#579575" ]
}
相关文档可在
这篇关于JqPlot饼图 - 更改饼图切片颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!