【发布时间】:2013-11-12 13:47:32
【问题描述】:
我正在使用 flot.js 和 flot 的类别插件来创建使用类别而不是 x 轴刻度的数值的条形图。
当我只使用一个系列时,它的效果非常好:http://jsfiddle.net/tFy46/1/。
但是,当我使用多个系列时,结果会堆叠在一起,而不是并排排列。
我的代码:
var graphCanvas = $('#graph-canvas'),
graphData = [
{
"color": "#f00",
"data": [
["1st Nov to 3rd Nov", 5.304752, 4.04044192]
]
},
{
"color": "#0f0",
"data": [
["1st Nov to 3rd Nov", 8.80990656, 3.86548928],
["11th Nov to 15th Nov", 37.89327872, -2.1734158399999997]
]
}
],
graphOptions = {
legend: {
show: false
},
series: {
bars: {
align: 'center',
fill: 0.7,
show: true
}
},
xaxis: {
mode: 'categories'
}
};
$.plot(graphCanvas, graphData, graphOptions);
(之前在 how to draw multiple bar charts grouped by category with flot js 上已经提出过这个问题,但“使用 flot 'categories' 插件”的公认答案不是一个有用的答案。)
【问题讨论】: