我试图将颜色设置为带有多个环的jqplot圆环图。我需要为每个切片填充特定的颜色,如下例所示:
我在文档中读到了我需要设置" varyBarColor " true ,并使用" 系列"一系列的" seriesColors "但它只显示默认颜色。
这是我到目前为止的代码:
var s1 = [['a',8], ['b',12]];
var s2 = [['a',3], ['b',17]];
var s3 = [['a',6], ['b',14]];
var s4 = [['a',10], ['b',10]];
var s5 = [['a',2], ['b',18]];
var plot4 = $.jqplot('divId', [s1, s2, s3, s4, s5], {
seriesDefaults: {
series: [
{seriesColors: [ "#8156a1", "#000"]},
{seriesColors: [ "#418cc8", "#ec79c0"]},
{seriesColors: [ "#ec79c0", "#f69c44",]},
{seriesColors: [ "#f69c44", "#fadb48"]},
{seriesColors: [ "#fadb48", "black"]}
],
renderer:$.jqplot.DonutRenderer,
rendererOptions:{
sliceMargin: 0,
lineWidth: 0,
startAngle: 90,
showDataLabels: false,
shadowAlpha: 0,
ringMargin:2,
varyBarColor: true,
thickness: 7
}
},
grid: {
background: 'transparent',
borderColor: 'transparent',
shadow: false,
drawGridLines: false,
gridLineColor: 'transparent',
borderWidth: '0'
}
});
关于如何使其发挥作用的任何想法?
提前致谢。
答案 0 :(得分:0)
好的,我设法解决了这个问题,(实际上是一个非常愚蠢的问题)。系列值应该在seriesDefaults之外,不像我在里面那样:
var plot4 = $.jqplot('divId', [s1, s2, s3, s4, s5], {
series: [
{seriesColors: [ "#8156a1", "#000"]},
{seriesColors: [ "#418cc8", "#ec79c0"]},
{seriesColors: [ "#ec79c0", "#f69c44",]},
{seriesColors: [ "#f69c44", "#fadb48"]},
{seriesColors: [ "#fadb48", "black"]}
],
seriesDefaults: {
renderer:$.jqplot.DonutRenderer,
rendererOptions:{
sliceMargin: 0,
lineWidth: 0,
startAngle: 90,
showDataLabels: false,
shadowAlpha: 0,
ringMargin:2,
varyBarColor: true,
thickness: 7
}
},
grid: {
background: 'transparent',
borderColor: 'transparent',
shadow: false,
drawGridLines: false,
gridLineColor: 'transparent',
borderWidth: '0'
}
});