Skip to content Skip to sidebar Skip to footer

Plotting Seconds, Minutes And Hours On The Yaxis With Highcharts

I have some data that looks like this: min='00:09' med='03:11' mean='23:39' max='12:40:26' I'd like to be able to be able to use these values as datapoints but I'm not sure how t

Solution 1:

If the times that you have are static strings, you can convert them into a datetime object...

//convert 'string'times into a timestamp (milliseconds)
//so long as your string times are consistently formatted
//e.g. "0:03:00" not "3:00"
var t = Date.parse("1-1-1 " + yourTime)

...But if you can turn them into a millisecond value at all, you should be fine.

Then use normal time format for the y-axis, and format it as you like using the date label format...

var chart = new HighChart({
    //...
    yAxis: {
        type: 'datetime', //y-axis will be in milliseconds
        dateTimeLabelFormats: { //force all formats to be hour:minute:second
            second: '%H:%M:%S',
            minute: '%H:%M:%S',
            hour: '%H:%M:%S',
            day: '%H:%M:%S',
            week: '%H:%M:%S',
            month: '%H:%M:%S',
            year: '%H:%M:%S'
        }
    }
});

Post a Comment for "Plotting Seconds, Minutes And Hours On The Yaxis With Highcharts"