我试图创建一个jqplot图表的小问题。
我想将所有2008年的数据放入一个类别并使用某种颜色进行设计,然后在2009年进行相同的操作。
目前我有这个输出:
how current chart looks (imgur link)
使用此代码:
$(document).ready(function(){
// For horizontal bar charts, x an y values must will be "flipped"
// from their vertical bar counterpart.
var plot2 = $.jqplot('tableTest', [
[[10,2008], [12,2008], [11,2008], [13,2008]],
[[2,2009], [4,2009], [6,2009], [3,2009],]
], {
seriesDefaults: {
renderer:$.jqplot.BarRenderer,
// Show point labels to the right ('e'ast) of each bar.
// edgeTolerance of -15 allows labels flow outside the grid
// up to 15 pixels. If they flow out more than that, they
// will be hidden.
pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
// Rotate the bar shadow as if bar is lit from top right.
shadowAngle: 135,
// Here's where we tell the chart it is oriented horizontally.
rendererOptions: {
barDirection: 'horizontal'
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
/*rendererOptions: {
groupLabels:['Fruits', 'Vegetables']
}*/
}
}
});
});
有没有人知道如何分开酒吧?
提前谢谢
答案 0 :(得分:0)
您添加自己的自定义刻度,并以稍微不同的方式格式化数据。我已在jsFiddle:
中对代码进行了调整$(document).ready(function(){
// For horizontal bar charts, x an y values must will be "flipped"
// from their vertical bar counterpart.
var ticks = ['2008', '2009'];
var plot2 = $.jqplot('tableTest', [[10, 2], [12, 3], [11, 6], [13, 3]], {
seriesDefaults: {
renderer:$.jqplot.BarRenderer,
// Show point labels to the right ('e'ast) of each bar.
// edgeTolerance of -15 allows labels flow outside the grid
// up to 15 pixels. If they flow out more than that, they
// will be hidden.
pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
// Rotate the bar shadow as if bar is lit from top right.
shadowAngle: 135,
// Here's where we tell the chart it is oriented horizontally.
rendererOptions: {
barDirection: 'horizontal'
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
}
});
});