Jquery Flot类别堆积条形图不堆叠

时间:2013-10-04 15:50:16

标签: jquery flot

所以我遇到了Flot的问题。我有正确的所有数据,但唯一的问题是我的数据没有堆叠。我有堆栈:是的,但是我做错了什么?

以下是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 个答案:

答案 0 :(得分:5)

确保在加载类别插件后加载堆栈插件