Calculate seconds, minutes, and hours on yAxis with Highcharts

I have some data that look like this:

min = "00:09" med = "03:11" mean = "23:39" max = "12:40:26"

I would like to be able to use these values ​​as datapoints, but I'm not sure how to build them, since they are not prime integers. Ideally, I would like the labels on the Y axis to display something like a “clock”, or if I used several y axes, then it could show “seconds” for the values ​​“min”, “minutes” for “average” , values, etc., adapting to the corresponding time window.

I'm not sure if I can use datetime objects since I only have a time value, not a date.

Any ideas would be appreciated and appreciated in advance.

+6
source share
1 answer

If you have static strings, you can convert them to a datetime object ...

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

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

Then use the regular time format for the y axis and format it as you like using the date stamp 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' } } }); 
+9
source

Source: https://habr.com/ru/post/902382/


All Articles