Give different color to each stack in stacked bar - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Give different color to each stack in stacked bar

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <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> 
      <script type="text/javascript">
Highcharts.chart('container', {
    chart: {/*from   w  w  w  .j  a  va2  s. c  o  m*/
        type: 'column'
    },
    title: {
        text: 'Stacked column chart'
    },
    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears']
    },
    plotOptions: {
       series: {
         stacking: 'normal'
      }
    },
    legend: false,
    series: [{
        name: 'Jane',
        data: [{
           y: 2,
          color: '#ff0000'
        }, {
           y: 3,
          color: '#00ff00'
        }, {
           y: 1,
          color: '#0000ff'
        }]
    }, {
        name: 'Joe',
        data: [{
           y: 1,
          color: '#990000'
        }, {
           y: 2,
          color: '#009900'
        }, {
           y: 3,
          color: '#000099'
        }]
    }, {
        name: 'John',
        data: [{
           y: 3,
          color: '#550000'
        }, {
           y: 1,
          color: '#005500'
        }, {
           y: 2,
          color: '#000055'
        }]
    }]
});

      </script>  
   </body>
</html>

Related Tutorials