Search code examples
amcharts4

AM/PM timeline in amCharts


I'm having an issue changing the timeline to show 12 hour time with AM/PM instead of 24 hour time.

Adding this line to the timeline chart correctly changes the tooltip to display in AM/PM format:

dateAxis.tooltipDateFormat = "hh:mm a";

According to the documentation adding this line should do the same for the timeline along the X-axis:

dateAxis.dateFormatter.dateFormat = "hh:mm a";

Here's the example I'm using to test.

It isn't working however and there don't seem to be any examples of this working that I can find.

Is this feature not yet working in v4?

Thanks


Solution

  • You have to set the date format directly on the dateAxis' dateFormats object as documented here, e.g.:

    dateAxis.dateFormats.setKey('hour', 'hh:mm a');
    

    Codepen