stacked bar chart creation - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

stacked bar chart creation

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>JOB PREF 3</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w w  w  .  j a v  a2  s  .  c  o  m
Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    credits: {
                enabled: false
            },
            exporting: {
               enabled: false
             },
    title: {
        text: 'Campus Placement Preferences'
    },
    xAxis: {
        categories: ['BACHELOR', 'MASTER', 'DIPLOMA', 'DOCTORATE'],
         labels: {
             enabled: true
         },
         minorTickLength: 0,
         tickLength: 0
          },
    yAxis: {
        min: 0,
        title: {
            text: ''
        },
        gridLineColor: 'transparent'
    },
    legend: {
        reversed: true
    },
    tooltip: {
                        headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                        pointFormat: '<span style="color:{point.color}"></span> <b>{point.y}%</b> of total 100%<br/>'
                    },
    plotOptions: {
        series: {
            stacking: 'percent'
        }
    },
    series: [{
        name: 'NO',
        color:'#70d8ff',
        data: [50, 30, 40, 70]
    }, {
        name: 'YES',
        color:'#1d3166',
        data: [50, 70, 60, 30]
    }]
});
    }

      </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; max-width: 800px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials