【问题标题】:how to draw multiple bar charts grouped by category with flot js如何使用flot js绘制按类别分组的多个条形图
【发布时间】:2013-02-22 18:53:34
【问题描述】:

我正在使用 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
        }
    }
);

【问题讨论】:

    标签: charts flot bar-chart


    【解决方案1】:

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

    【讨论】:

    • 对不起,我不得不投反对票,因为这不能回答问题。在示例中,每个类别都给出一个值。但问题是如何使用类别来绘制多个系列,大概并排。
    • @DerekHenderson 你是对的;我显然误读了这个问题。删除我的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 2021-11-25
    相关资源
    最近更新 更多