codebot
codebot

Reputation: 697

How can I have month and year in x axis, display as number in Highcharts?

Right now in my highcharts I have x axis displaying dates. The date displayed is in the following format

30 Nov 2019 10:00

My settings for x axis

          xAxis:{
            type:'datetime',
            title:
            {
              align:'high'
            }, 
            labels: {
              padding: 50,
              format: '{value:%e %b %Y %H:%M}',
              style: {
                fontSize: '10px'
              }
            }
          }, 

How can I have the date displayed as such

30 11 19 10:00

Thanks

Upvotes: 0

Views: 110

Answers (1)

Antoine
Antoine

Reputation: 4029

You can use the formats shown on the documentation: https://api.highcharts.com/class-reference/Highcharts#.dateFormat:

      xAxis:{
        type:'datetime',
        title:
        {
          align:'high'
        }, 
        labels: {
          padding: 50,
          format: '{value:%d %m %y %H:%M}',
          style: {
            fontSize: '10px'
          }
        }
      }, 

More generaly, these formats are used widely across many programming languages, and the reference is PHP's strftime implementation.

Upvotes: 1

Related Questions