我遇到了这个我无法解决的问题。我想创建一个Flot堆栈图表。图表是由不遵守颜色顺序创建的,如下图所示:
如果你注意到在2010-2011
和2011-2012
中,蓝色必须是第一个。
这里用于获取此代码的代码:
dataset = [ {label: "Staff", data: staffRep, color: "#0077FF"}, {label: "Post-doc", data: postdocRep, color: "#7D0096"}, {label: "Student", data: studentRep, color: "#DE000F"} ];
var bar_options = {
series: {
stack: true,
bars: {
barWidth: 0.2,
lineWidth: 0,
show: true
}
},
bars: {
align: "center"
},
xaxis: {
tickLength: 0,
ticks: ticks,
axisLabel: 'Reporting period',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 13,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 15
},
yaxis: {
//max: max + j - j/2, // to avoid interference between bars and legend
axisLabel: 'Personnel',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 13,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
},
grid: {
hoverable: true,
borderWidth: 0
},
legend: {
backgroundColor: "#EEE",
labelBoxBorderColor: "none"
},
colors:["#004078","#207800", "#613C00"]
};
$.plot($("#barchart"), dataset, bar_options);