如何使用flot js绘制按类别分组的多个条形图

时间:2013-02-22 18:53:34

标签: charts flot bar-chart

我正在使用flot库来显示条形图,我需要以这种方式按特定值分组:

|
|          +----+        +----+    
|          |    |        |    |    
|          |    |        |    |    
|          |    |        |    |    
| +----+   |    |        |    |    
| |    |   |    |        |    |    
| |    |   |    |        |    |    
| |    |   |    |        |    |    
|-+----+---+----+--------+----+----
   val 1    val2          val3
    category #1        category #2

感谢Sergey G.为Ascii:)

我将变量d1,d2,d3分别设置为条形1,2和3的值(按类别排序)。 问题是: 如何添加以下滴答类别? 对不起我的“谷歌翻译”英文,非常感谢你!

代码:

$.plot(
    $("#placeholder"),
    [

            {
        label: labelChart,
        data: d1,
        color: '#92d5ea',
        bars: {
            show: true,
            barWidth: 0.5,
            align: "center",
            order:2
        },   

       multiplebars:true  
    },
    {
        label: labelChart,
        data: d2,
        color: '#92d5ea',
        bars: {
            show: true,
            barWidth: 0.5,
            align: "center",
            order:3
        },   

       multiplebars:true  
    },
    {
        label: labelChart,
        data: d3,
        color: '#92d5ea',
        bars: {
            show: true,
            barWidth: 0.5,
            align: "center",
            order:3
        },   

       multiplebars:true  
    }


    ],
    {
        xaxis: {
            ticks: ticksData
        }, 

        yaxis: { 
            min:0
        }
    }
);

1 个答案:

答案 0 :(得分:-4)

使用类别插件,如this example中所示。