Jquery Flot category stacked bar chart not stacking

无人久伴 提交于 2019-12-23 20:20:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!