stackLabels with separate data in chart - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

stackLabels with separate data in chart

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> 
      <div id="container" style="height: 400px"></div> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
Highcharts.chart('container', {
    chart: {/*  ww  w. j  a  v  a  2  s . c  o  m*/
        type: 'column'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    yAxis: {
        stackLabels: {
            style: {
                color: 'red'
            },
            enabled: true,
            useHTML: true,
            formatter: function() {
               var firstLabel = Math.round((this.points[0][1] - this.points[0][0]) * 10) / 10,
                 secondLabel = this.points[0][0]
              return `<span>${firstLabel}</span></br>
                          <span>${secondLabel}</span>`
            },
                 y: -15
        }
    },
    plotOptions: {
        column: {
            stacking: 'normal',
            pointPadding: 0,
            groupPadding: 0,
            dataLabels: {
                enabled: false,
            }
        }
    },
    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }, {
        data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
    }]
});

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

Related Tutorials