【问题标题】:Highcharts multilevel categoriesHighcharts 多级类别
【发布时间】:2013-07-30 12:17:35
【问题描述】:

我正在使用 highcharts,需要获取列出的类别和子类别。

例如:

我有一些运动员,我希望按地点和性别列出奖牌。

因此,必须列出所有奖牌类型,并且将类别分为男性和女性

    |    GOLD    |   SILVER   |   BRONZE  |
    |male|female||male|female||male|female|
    ---------------------------------------
    | cl | cl    | cl |  cl   | cl |  cl  |

*cl = 一些列,其中包含按性别获得的该类型奖牌的数据

这在highcharts中是否可行?如果可以,如何实现?

【问题讨论】:

    标签: split highcharts categories


    【解决方案1】:

    这是一个旧请求,但由于我不得不做一些类似的事情,所以我会分享解决方案 - 基于 HighCharts 的多类别插件 - 这是来自 jsfiddle 的代码 -http://jsfiddle.net/fieldsure/Lr5sjh5x/2/

    $(function () {
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: "container",
                type: "column",
                borderWidth: 5,
                borderColor: '#e8eaeb',
                borderRadius: 0,
                backgroundColor: '#f7f7f7'
            },
            title: {
                style: {
                    'fontSize': '1em'
                },
                useHTML: true,
                x: -27,
                y: 8,
                text: '<span class="chart-title"> Grouped Categories with 2 Series<span class="chart-href"> <a href="http://www.blacklabel.pl/highcharts" target="_blank"> Black Label </a> </span> <span class="chart-subtitle">plugin by </span></span>'
            },
            yAxis: [{ // Primary yAxis
                labels: {
                    format: '${value}',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                },
                title: {
                    text: 'Daily Tickets',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                }
            }, { // Secondary yAxis
                title: {
                    text: 'Invoices',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                },
                labels: {
                    format: '${value}',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                },
                opposite: true
            }]
            ,
            series: [{
                name: 'Daily',
                type: 'column',
                yAxis: 1,
                data: [4, 14, 18, 5, 6, 5, 14, 15, 18],
                tooltip: {
                    valueSuffix: ' mm'
                }
    
            }, {
                name: 'Invoices',
                type: 'column',
                data: [4, 17, 18, 8, 9, 5, 13, 15, 18],
                tooltip: {
                    valueSuffix: ' °C'
                }
            }],
            xAxis: {
                categories: [{
                    name: "1/1/2014",
                    categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
                }, {
                    name: "1/2/2014",
                    categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
                }, {
                    name: "1/3/2014",
                    categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
                }]
            }
        });
    });
    

    【讨论】:

      【解决方案2】:

      我认为您需要一个堆积条形图。根据您的数据跟踪示例。 http://jsfiddle.net/AtGRH/

      $(function () {
              $('#container').highcharts({
                  chart: {
                      type: 'bar'
                  },
                  title: {
                      text: 'Stacked bar chart'
                  },
                  xAxis: {
                      categories: ['Gold', 'Silver', 'Bronze']
                  },
                  yAxis: {
                      min: 0,
                      title: {
                          text: 'Total fruit consumption'
                      }
                  },
                  legend: {
                      backgroundColor: '#FFFFFF',
                      reversed: true
                  },
                  plotOptions: {
                      series: {
                          stacking: 'normal'
                      }
                  },
                      series: [{
                      name: 'Male',
                      data: [5, 3, 4 ]
                  }, {
                      name: 'Female',
                      data: [2, 2, 3]
                  },]
              });
          });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-11
        • 1970-01-01
        • 2022-11-20
        • 2019-05-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多