0

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

例如:

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

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

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

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

在highcharts中这可能吗?如果是,怎么做?

4

2 回答 2

11

这是一个旧请求,但由于我不得不做一些类似的事情,我想我会分享解决方案 - 基于 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"]
            }]
        }
    });
});
于 2014-11-16T16:43:53.710 回答
1

我认为你需要一个堆积条形图。根据您的数据跟踪示例。 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]
            },]
        });
    });
于 2013-07-30T12:27:40.387 回答