问题
So I am having an issue with Flot. I have all the data right, but the only problem is my data doesn't stack. I have stack: true, but what am I doing wrong?
Here is the output of the three arrays in 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>
回答1:
Make sure you load the stack plugin after you load the categories plugin.
来源:https://stackoverflow.com/questions/19185514/jquery-flot-category-stacked-bar-chart-not-stacking