3
votes

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
Seems to be working as expected for me: jsfiddle.net/brianpeiris/uQjYebrianpeiris
Are you including the stacking plugin?DNS

1 Answers

5
votes

Make sure you load the stack plugin after you load the categories plugin.