LittleLebowski
LittleLebowski

Reputation: 7941

How to make a simple bar graph and not stacked bar graph with Flot Charts?

I'm rendering a bar chart with Flot charts. It's working fine. The following is the code:

var d1 = [
            [1,20],
            [2,30],
            [3,15],
            [4,45],
            [5,79]
            ];


                $.plot($("#mychart"), [d1], {
                grid: {
                        show: true,
                        clickable: true, 
                        hoverable: true

                },
                    series: {
                        stack: 0,

                        bars: {
                            show: true,
                            barWidth: 0.6,
                            fill: 0.6,
                            align:'center'
                        }
                    },

                colors: ["#F4A70C"]

                });

My data is fetched dynamically from the server. Even that is working fine. The problem is I'm using the following commands to redraw the graph:

            flot.setData(data);
            flot.setupGrid();
            flot.draw();

The output I get is a stacked bar graph. I want a new bar graph to be rendered everytime. I've set stack=0, but that doesn't seem to affect anything. Please guide me.

Upvotes: 1

Views: 681

Answers (1)

DNS
DNS

Reputation: 38189

The stack plugin sees values other than null, undefined, and false as true. So replace your zero with 'false' and you should be okay.

Upvotes: 3

Related Questions