Olga
Olga

Reputation: 129

How to make highcharts display date in hh:mm:ss format, not as timestamp?

I need to display xAsis labels as hh:mm:ss time format, but highcharts is displaying labels as timestamp it's getting from BE.

I've tried setting format to xAsis object like this:

   xAsis: {
        type: "datetime",
        dateTimeLabelFormats: {
            second: "%H:%M:%S"
        },
        labels: {
            formatter: function () {
                return (new Date(this.value).toLocaleTimeString();
            }
        }

It should have shown time as 11:30:23, but it still shows label as timestamp.

Upvotes: 0

Views: 107

Answers (1)

ppotaczek
ppotaczek

Reputation: 39139

You have a typo - instead of xAsis there should be xAxis:

xAxis: {
    ...
}

Live demo: http://jsfiddle.net/BlackLabel/pa7516c0/

API Reference: https://api.highcharts.com/highcharts/xAxis

Upvotes: 1

Related Questions