Total, Groups and Average With HighCharts

by Gabriel Correa

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.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', {
    title: {
        text: 'Combination chart'
    },
    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
    },
    labels: {
        items: [{
            html: 'Total fruit consumption',
            style: {
                left: '50px',
                top: '18px',
                color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
            }
        }]
    },
    series: [{
        type: 'column',
        name: 'Jane',
        data: [5347.70, 2347.70, 3347.70, 1347.70, 4347.70]
    }, {
        type: 'column',
        name: 'John',
        data: [5347.70, 2347.70, 3347.70, 1347.70, 4347.70]
    }, {
        type: 'column',
        name: 'Joe',
        data: [5347.70, 2347.70, 3347.70, 1347.70, 4347.70]
    }, {
        type: 'spline',
        name: 'Average',
        data: [5347.70, 2347.70, 3347.70, 1347.70, 4347.70],
        marker: {
            lineWidth: 2,
            lineColor: Highcharts.getOptions().colors[3],
            fillColor: 'white'
        }
    }, {
        type: 'pie',
        name: 'Total consumption',
        data: [{
            name: 'Limite',
            y: 13,
            color: Highcharts.getOptions().colors[0] // Jane's color
        }, {
            name: 'Balanço',
            y: 23,
            color: Highcharts.getOptions().colors[1] // John's color
        }],
        center: [13, 23],
        size: 100,
        showInLegend: false,
        dataLabels: {
            enabled: false
        }
    }]
});