Set date time label format for series - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

Set date time label format for series

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.9.1.js"></script> 
      <script type="text/javascript">
$(function() {/*from   w  w  w .  ja  v a  2s  .  com*/
  Highcharts.chart('container', {
    chart: {
      type: 'spline'
    },
    title: {
      text: 'Snow depth at Vikjafjellet, Norway'
    },
    subtitle: {
      text: 'Irregular time data in Highcharts JS'
    },
    xAxis: {
      type: 'datetime',
      dateTimeLabelFormats: { // don't display the dummy year
        month: '%e. %b',
        year: '%b'
      },
      title: {
        text: 'Date'
      }
    },
    yAxis: {
      title: {
        text: 'Snow depth (m)'
      },
      min: 0
    },
    tooltip: {
      formatter: function() {
        return 'Extra data: <b>' + this.point.myData + '</b>';
      }
    },
    plotOptions: {
      spline: {
        marker: {
          enabled: true
        }
      }
    },
    series:
      [{
      name: 'Foo',
         keys: ['x', 'y', 'myData'],
      data: [
        [Date.UTC(2016, 7, 29), 1.0, 'firstPoint'],
        [Date.UTC(2016, 9, 29), 2.0, 'secondPoint'],
        [Date.UTC(2016, 9, 29), 3.18, 'thirdPoint']
      ],
    }],
  });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials