x-axis datetime with different format of first and last boundary labels - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

x-axis datetime with different format of first and last boundary labels

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Datetime, different format start/end</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"></div> 
      <script type="text/javascript">
Highcharts.chart('container', {
  xAxis: {// ww w  .jav  a 2 s.c  o m
    type: 'datetime',
      //endOnTick: true,
    //startOnTick: true,
    labels: {
      formatter: function() {
        if (this.isFirst || this.isLast) {
          return Highcharts.dateFormat('%a %e %b - %H %M %S', this.value);
        } else {
          return Highcharts.dateFormat('%H %M %S', this.value);
        }
      }
    }
  },
  series: [{
    data: [
      [1505347200000, 29.9],
      [1505357200000, 71.5],
      [1505367200000, 106.4],
      [1505377200000, 129.2],
      [1505387200000, 144.0],
      [1505397200000, 176.0],
      [1505417200000, 135.6],
      [1505427200000, 148.5],
      [1505433540000, 54.4]
    ]
  }]
});

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

Related Tutorials