Stacked bar chart with 100 percent width using bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Stacked bar chart with 100 percent width using 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" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function() {//from   w  ww .  j av a  2s. co  m
  Highcharts.chart('container', {
    chart: {
      type: 'bar',
      marginRight: 30,
    },
    plotOptions: {
      series: {
        stacking: 'normal',
        pointWidth: 5,
        dataLabels: {
          enabled: true,
          verticalAlign: 'bottom',
          style: {
            color: 'black'
          }
        },
        enableMouseTracking: false,
        borderWidth: 0
      }
    },
    legend: {
      enabled: false
    },
    yAxis: {
      visible: false,
      minPadding: 0,
      maxPadding: 0,
      max: 8,
      min: 0
    },
    xAxis: {
      visible: false
    },
    series: [{
      color: 'grey',
      data: [3, 5, 7],
      dataLabels: {
        align: 'right',
        format: '{point.y} %'
      }
    }, {
      color: 'green',
      data: [{
        y: 5,
        label: 'Footbal'
      }, {
        y: 3,
        label: 'Soccer'
      }, {
        y: 1,
        label: 'Baseball'
      }],
      dataLabels: {
        align: 'left',
        format: '{point.label}'
      }
    }]
  });
});

      </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