remove gap below area chart when all values are zero - Javascript highcharts

Javascript examples for highcharts:Area Chart

Description

remove gap below area chart when all values are zero

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> 
      <div id="container1" style="height: 200px"></div> 
      <div id="container2" style="height: 200px"></div> 
      <script type="text/javascript">
    Highcharts.wrap(Highcharts.Axis.prototype, 'setTickPositions', function(proceed, secondPass) {
      proceed.call(this, secondPass);//from w  w w .  j  ava2  s . c om
      if (this.tickPositions.length === 1 && this.options.alignToAxis) {
        this.min = 0;
        this.max *= 2;
      }
    });
    Highcharts.chart('container1', {
      yAxis: {
        alignToAxis: true
      },
      series: [{
        type: 'area',
        data: [0, 0, 0, 0]
      }]
    });
    Highcharts.chart('container2', {
      yAxis: {
        alignToAxis: false
      },
      series: [{
        type: 'area',
        data: [0, 0, 0, 0]
      }]
    });

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

Related Tutorials