我正在尝试设置jqplot条形图条的颜色.总会有六个条形图,分为两组条形图.以下是绘制数据的示例:
line1 = [6000, 5000, 5500];
line2 = [16000, 10000, 14000];
Run Code Online (Sandbox Code Playgroud)
到目前为止我使用了以下内容:
seriesColors: ["#F3CBBF", "#BFDDE5", "#CF3501", "#027997", "#CF3501", "#027997"],
Run Code Online (Sandbox Code Playgroud)
但是jqplot每次在前两个条之间交替,而不是使用所有声明的颜色.这可能是因为它只确定存在2个系列,每组数据一个.
有没有办法明确设置条形颜色?
Mat*_*dak 31
我使用varyBarColor方法执行此操作,因此您可以像已经完成的那样在简单数组中列出条形图的不同颜色,但如果只有一个系列,则会为每个条形图使用这些颜色.这是我的代码示例:
plot1 = $.jqplot('chart1', [s1], {
title: 'Example Income Graph',
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions:{ varyBarColor : true },
pointLabels: { show : true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
label:'Net Growth (%)',
ticks: ticks
},
yaxis:{
label:'Income (£)',
tickOptions:{ formatString:'%d'},
autoscale:true,
min:0,
max:10000
}
},
seriesColors: [ "#eee", "#ccc", "#999"],
highlighter: { show: false }
});
Run Code Online (Sandbox Code Playgroud)
在这张图中,我有一个系列有3个条形,它们各自是不同颜色的灰色.