Display Different Number of Groups in Stacked Column Chart - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

Display Different Number of Groups 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">
    $(window).load(function(){//w  ww  .j a  va 2  s  .  c o m
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'column'
            },
            title: {
                text: 'Total fruit consumtion, grouped by gender'
            },
            xAxis: {
                categories: ['2009', '2010', '2011']
            },
            yAxis: {
                allowDecimals: false,
                min: 0,
                title: {
                    text: 'Number of fruits'
                }
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.options.year +' '+this.point.options.scenario+'</b><br/>'+
                        this.series.name +': '+ this.y +'<br/>'+
                        'Total: '+this.point.stackTotal;
                }
            },
            plotOptions: {
                column: {
                    stacking: 'normal'
                }
            },
            series:[
                {name:'Apples', color:'green', data:[{x:0, y:10, year: '2009', scenario: 'historic'}, {x:1, y:11,year: '2010',  scenario: 'historic'} ]},
                                     {name:'Oranges', color:'orange', data:[{x:0, y:2, year: '2009',  scenario:'historic'}, {x:1, y:5, year: '2010', scenario:'historic'}]},
                {name:'Apples',color:'green', data:[{x:1.75, y:12, year:'2011',scenario:'optimistic'}], showInLegend: false },
                {name:'Apples', color:'green',data:[{x:2.25, y:3,year:'2011',  scenario:'conservative'}], showInLegend: false },
     {name:'Oranges',color:'orange',  data:[{x:1.75, y:11, year:'2011',scenario:'optimistic'}], showInLegend: false},
    {name:'Oranges',color:'orange',  data:[{x:2.25, y:6, year:'2011',scenario:'conservative'}], showInLegend: false},
    ]
        });
    });
});
    });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials