plot x axis next to 0th y axis tick label in case of negative data? - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

plot x axis next to 0th y axis tick label in case of negative data?

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.src.js"></script> 
      <div id="container"></div> 
      <script type="text/javascript">
(function(H) {// w w w. j  a  v  a  2  s  .c  om
  H.wrap(H.Axis.prototype, 'render', function(proceed) {
    var chart = this.chart,
      xAxis, yAxis, extremes, crossing;
    if (typeof this.options.zeroCrossing === 'boolean') {
      xAxis = chart['xAxis'][0];
      yAxis = chart['yAxis'][0];
      extremes = yAxis.getExtremes();
      crossing = Math.abs(extremes.min);
      this.offset = yAxis.toPixels(crossing, true) / 2;
    }
    proceed.call(this);
  });
}(Highcharts));
var chart = Highcharts.chart('container', {
  chart: {
    type: 'bar'
  },
  xAxis: {
    categories: ['a', 'b', 'c', 'd'],
    tickInterval: 1,
    visible: true,
          zeroCrossing: true
  },
  yAxis: {
    min: -2,
    max: 5,
    visible: true
  },
  series: [{
    data: [5, 3, -2, 3],
    borderWidth: 0
  }]
});

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

Related Tutorials