Create stacked bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Create stacked bar 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">
    var VanillaRunOnDomReady = function() {
var chart = new Highcharts.Chart({
  chart: {/*from  w w w  .  j  av  a 2  s.  c o m*/
    type: 'bar',
    renderTo: 'container'
  },
  xAxis: {
    tickColor: '#FFFFFF',
    tickWidth: 1,
    categories: [''],
    labels: {
      enabled: false
    },
    visible: false
  },
  title: {
    text: ''
  },
  yAxis: {
    title: {
      text: ''
    },
    labels: {
      enabled: false
    },
    visible: false
  },
  legend: {
    enabled: false
  },
  plotOptions: {
    series: {
      stacking: 'normal',
      borderWidth: 0
    }
  },
  tooltip: {
    enabled: false
  },
  colors: ['#999999', '#8BF30D', '#FF0000'],
  series: [{
    name: '',
    data: [1]
  }, {
    name: '',
    data: [2]
  }, {
    name: '',
    data: [1]
  }]
});
    }
var alreadyrunflag = 0;
if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", function(){
        alreadyrunflag=1;
        VanillaRunOnDomReady();
    }, false);
else if (document.all && !window.opera) {
    document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>');
    var contentloadtag = document.getElementById("contentloadtag")
    contentloadtag.onreadystatechange=function(){
        if (this.readyState=="complete"){
            alreadyrunflag=1;
            VanillaRunOnDomReady();
        }
    }
}
window.onload = function(){
  setTimeout("if (!alreadyrunflag){VanillaRunOnDomReady}", 0);
}

      </script> 
   </head> 
   <body> 
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
      <script src="https://code.highcharts.com/2.1.5/highcharts.js"></script> 
      <div id="container"> 
      </div>  
   </body>
</html>

Related Tutorials