X-Axis with tick position setting in line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

X-Axis with tick position setting in line 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> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px; width: 600px; margin: 0 auto"></div> 
      <script type="text/javascript">
Highcharts.chart('container', {
    title: {/* ww  w.  jav  a 2 s .  c om*/
        text: 'Custom tick positions'
    },
    subtitle: {
        text: 'through axis.tickPositions and axis.tickPositioner'
    },
    xAxis: {
        tickPositions: [0, 1, 2, 4, 8]
    },
    yAxis: {
        tickPositioner: function () {
            var positions = [],
                tick = Math.floor(this.dataMin),
                increment = Math.ceil((this.dataMax - this.dataMin) / 6);
            if (this.dataMax !== null && this.dataMin !== null) {
                for (tick; tick - increment <= this.dataMax; tick += increment) {
                    positions.push(tick);
                }
            }
            return positions;
        }
    },
    series: [{
        data: [
            [0, 1],
            [1, 3],
            [2, 2],
            [4, 4],
            [8, 3]
        ]
    }]
});

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

Related Tutorials