如何从列到colum和pie渲染高级图表(每个类别)

时间:2017-08-27 10:48:13

标签: javascript jsp highcharts

对不起。我只会说很少的英语。

Fiddle

HTML:

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

使用Javascript:

Highcharts.chart('container', {

    chart: {
        type: 'column'
    },

    title: {
        text: 'Total Work'
    },

    xAxis: {
        categories: ['2013', '2014', '2015', '2016', '2017']
    },

    yAxis: {
        allowDecimals: false,
        min: 0,
        title: {
            text: 'Number of fruits'
        }
    },

    tooltip: {
        formatter: function () {
            return '<b>' + this.x + '</b><br/>' +
                this.series.name + ': ' + this.y + '<br/>' +
                'Total: ' + this.point.stackTotal;
        }
    },

    plotOptions: {
        column: {
            stacking: 'normal'
        }
    },

    series: [{
        name: 'B1',
        data: [5, 3, 4, 7, 2],
        stack: 'male'
    }, {
        name: 'B2',
        data: [3, 4, 4, 2, 5],
        stack: 'male'
    }, {
        name: 'B3',
        data: [2, 5, 6, 2, 1],
        stack: 'female'
    }, {
        name: 'B4',
        data: [3, 0, 4, 4, 3],
        stack: 'gay'
    }]
});

我想B1,B2到列并将B3,B4转换成每个catagory的饼。

喜欢这张图片: enter image description here

感谢所有方向

1 个答案:

答案 0 :(得分:0)