Stacked column

author(s): Torstein Hønsi

by anikettiwari

HTML

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

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

JavaScript

Highcharts.chart('container', {
     
    chart: {
        type: 'column'
    },
   
    title: {
        text: 'Stacked column chart'
    },
    xAxis: {
        categories: ['2011', '2012', '2013', '2014', '2015']
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Total fruit consumption'
        },
        /* stackLabels: {
            enabled: true,
            style: {
                fontWeight: 'bold',
                color: ( // theme
                    Highcharts.defaultOptions.title.style &&
                    Highcharts.defaultOptions.title.style.color
                ) || 'gray'
            }
        } */
    },
  /*   legend: {
        align: 'right',
        x: -30,
        verticalAlign: 'top',
        y: 25,
        floating: true,
        backgroundColor:
            Highcharts.defaultOptions.legend.backgroundColor || 'white',
        borderColor: '#CCC',
        borderWidth: 1,
        shadow: false
    }, */
     plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                 //   enabled: true,
                   // color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                    style: {
                  //      textShadow: '0 0 3px black'
                    }
                }
            }
        },
    tooltip: {
        headerFormat: '<b>{point.x}</b><br/>',
        pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
    },
    plotOptions: {
        column: {
            stacking: 'normal',
            dataLabels: {
                //enabled: true
            }
        }
    },
    series: [{
        index: 0,
        name: 'John',
        data: [5, 3, 4, 7, 2]
    }, {
    		index: 1,
        name: 'Jane',
        data: [2, 2, 3, 2, 1]
    }]
});