Get next xAxis label in line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Get next xAxis label in 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.8.3.js"></script> 
      <script type="text/javascript">
(function ($) { // encapsulate jQuery
    $(function () {/*from   w  w w.j  a v  a2s  .c  o m*/
        var detailChart;
        var start = new Date(2013, 1, 12, 0, 0, 0, 0);
        var end = new Date(2013, 1, 14, 0, 0, 0, 0);
        var seriesOptions = [];
        seriesOptions.push({
            name: "Temp",
            data: [
                [1, 70.0],
                [2, 70.0],
                [3, 70.0],
                [4, 66.0],
                [5, 70.0]
            ],
            type: 'spline'
        });
        detailChart = new Highcharts.Chart({
            chart: {
                renderTo: 'detail-container',
                zoomType: 'x'
            },
            xAxis: {
                categories: ['2012-01','2012-02','2012-03'],
                events: {
                    afterSetExtremes: function (event) {
                        var min = Math.round(event.min);
                        var label = this.categories[min];
                        console.log(label);
                    }
                }
            },
            series: seriesOptions
        });
    });
})(jQuery);

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <div id="detail-container" style="height: 700px"></div>  
   </body>
</html>

Related Tutorials