问题
I use flot to display simple bar charts. I have single dataset like [ [0,5], [1,6], [2,3], [4,1] ]
and I am using this simple code:
myChart = $.plot($('#graphFlot'), [{
data: mdata,
bars: { show: true, fill: 0.9 }
}]
);
Now I would like to display various colors and labels for each bar. Example bar chart here is how it should look like.
I've browsed through many examples and documentation and still do not know how to set this. Is this possible?
回答1:
Put each bar in its own series and give each series a different label.
回答2:
var mdata = [ [0,5], [1,6], [2,3], [4,1]]; var bar_array = [];
$.each(mdata, function(i, bar) { bar_array.push({ data: [bar], bars: { show: true, fill:0.9 } }); });
myChart = $.plot($('#graphFlot'), bar_array);
回答3:
To my knowledge there's no setting in Flot or Flotr2 that allows you to do this. I managed to get this done by making changes to the code that renders the barchart in flotr2.js
来源:https://stackoverflow.com/questions/11827404/flot-bar-chart-with-individual-colors-and-labels