Restricting nth label on a category axis for line chart - Javascript highcharts

Javascript examples for highcharts:Chart Axis

Description

Restricting nth label on a category axis for line 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://code.jquery.com/jquery-1.12.1.min.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*w w  w  .  ja v a 2 s  .  co m*/
var options = {
  yAxis: {
    categories: getData('Category:'),
    tickPositioner: function() {
       var ticks = this.tickPositions,
            last = ticks.length - 1;
      if (ticks[last] > this.dataMax) {
         ticks.splice(last, 1, this.dataMax); // replace last tick with current max
      }
      return ticks;
    }
  },
  series: [{
    data: getData(0)
  }]
};
var chart = $('#chart').highcharts(options);
function getData(prefix) {
  var d = [],
    i = 160;
  while (i--) d.push(prefix + i);
  return d;
}
    }

      </script> 
   </head> 
   <body> 
      <div id="chart"> 
      </div>  
   </body>
</html>

Related Tutorials