我在使用Flot时遇到了问题。我的数据是正确的,但唯一的问题是我的数据没有堆叠。我已经设置了stack: true,但我做错了什么?
以下是php中三个数组的输出:
[["Lifting 1",4],["go 2",0],["Hub",0]]
[["Lifting 1",1],["go 2",106],["Hub",92]]
[["Lifting 1",50],["go 2",24],["Hub",46]]
<script type="text/javascript">
$(function() {
var d1 = <?php echo json_encode($dataset_inb_dmg01); ?>;
var d2 = <?php echo json_encode($dataset_inb_dmg02); ?>;
var d3 = <?php echo json_encode($dataset_inb_dmg03); ?>;
function plotWithOptions() {
$.plot("#placeholder", [ d1, d2, d3 ], {
series: {
stack: true,
bars: {
show: true,
barWidth: 0.6,
align: "center"
}
},
xaxis: {
mode: "categories",
tickLength: 0
}
});
}
plotWithOptions();
});
</script>