简体   繁体   English

如何使用Flot Charts制作简单的条形图而不是堆积条形图?

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

I'm rendering a bar chart with Flot charts. 我正在使用Flot图表渲染条形图。 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. 我设置了stack = 0,但这似乎并没有影响任何东西。 Please guide me. 请指导我。

The stack plugin sees values other than null, undefined, and false as true. 堆栈插件将null,undefined和false以外的值视为true。 So replace your zero with 'false' and you should be okay. 所以用'false'替换你的零,你应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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