Multiple time series in stacked column chart - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

Multiple time series in stacked column chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {//from  w  w w  . j  av  a 2s . c o  m
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Total fruit consumtion, grouped by gender'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },
        yAxis: [{
            allowDecimals: false,
            min: 0,
            title: {
                text: 'Number of eaten fruits'
            }
        }, {
            allowDecimals: false,
            min: 0,
            title: {
                text: 'Number of bought else'
            }
        }],
        tooltip: {
            formatter: function () {
                  console.log(this);
                return '<b>' + this.x + '</b><br/>' +
                    this.series.name + ': ' + this.y + '<br/>' +
                    'Total: ' + this.point.stackTotal;
            }
        },
        plotOptions: {
            column: {
                stacking: 'normal'
            }
        },
        series: [{
            name: 'John-eaten',
            id: 'john',
            data: [5, 3, 4, 7, 2],
            stack: 'eaten'
        },{
            name: 'Joe-eaten',
            id: 'joe',
            data: [3, 4, 4, 2, 5],
                  stack: 'eaten'
        }, {
            name: 'Jane-eaten',
            id: 'jane',
            data: [2, 5, 6, 2, 1],
                  stack: 'eaten'
        }, {
            name: 'Janet-eaten',
            id: 'janet',
            data: [3, 0, 4, 4, 3],
                  stack: 'eaten'
        },{
            name: 'John-bought',
            color: Highcharts.getOptions().colors[0],
            linkedTo: 'john',
            data: [6, 4, 5, 8, 3],
                  stack: 'bought'
        }, {
            name: 'Joe-bought',
            color: Highcharts.getOptions().colors[1],
            linkedTo: 'joe',
            data: [2, 3, 3, 1, 4],
                  stack: 'bought'
        }, {
            name: 'Jane-bought',
            color: Highcharts.getOptions().colors[2],
            linkedTo: 'jane',
            data: [3, 6, 7, 3, 2],
                  stack: 'bought'
        }, {
            name: 'Janet-bought',
            color: Highcharts.getOptions().colors[3],
            linkedTo: 'janet',
            data: [2, 0, 3, 3, 2],
                  stack: 'bought'
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <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>  
   </body>
</html>

Related Tutorials