我正在使用 jqplot 绘制饼图和圆环图。我正在使用“seriesColors”为切片提供自定义颜色http://www.jqplot.com/docs/files/jqplot-core-js.html#jqPlot.seriesColors
系列颜色:[“0571B0”、“#5E3C99”、“#008837”]
如果数据(要传递的数组值)只有三个值,那么它会正确显示颜色。但如果有超过 3 个值,它只会以黑色显示该切片。它不会从一开始就重复/重用颜色(如文档中所述)。
这里是:
var s2 = [['a', 8], ['b', 12], ['c', 6]];
var plot1 = $.jqplot('div_1', [s2], {
title: 'Chart 1',
seriesDefaults:{
renderer:$.jqplot.DonutRenderer ,
rendererOptions:{
startAngle: -90,
innerDiameter: 100,
showDataLabels: true,
dataLabels:'percent'
}
},
seriesColors: ["#0571B0", "#5E3C99", "#008837"],
highlighter: {
show: true
},
legend: { show:true, rendererOptions: {numberRows: 1}, location: 's', placement: 'outsideGrid'}
});
但是如果我在数组中添加第 4 个值,颜色就不会被重用。即如果我将上面的数组修改为
var s2 = [['a', 8], ['b', 12], ['c', 6], ['d', 9]];
然后第 4 个切片 ('d') 以黑色显示。
我该如何解决?