简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM