bricolagezero2
Posts: 13
Joined: Fri May 27, 2022 5:48 pm

Minutes to HH:MM

Hello!

I am using Highcharts bar chart within a Wordpress plugin (so I do not have a proper JS fiddle), but they do allow you to add standard Highcharts customization using hooks.

My question is - currently my data source has a sum of hours and dates. For the hours, I'd like to display them as HH:MM as opposed to a numeric string (x,xxx).

Is there a way to convert this right before the bar chart is rendered?

Thank you!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Minutes to HH:MM

Hello,

I don't quite understand what you mean. Could you reproduce this based on this JsFiddle demo: https://jsfiddle.net/BlackLabel/yz8eutqf/?

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
bricolagezero2
Posts: 13
Joined: Fri May 27, 2022 5:48 pm

Re: Minutes to HH:MM

michal.f wrote: Mon Jun 27, 2022 5:20 pm Hello,

I don't quite understand what you mean. Could you reproduce this based on this JsFiddle demo: https://jsfiddle.net/BlackLabel/yz8eutqf/?

Best regards!
Thank you for your reply! Can you please look at the attached image. The "duration" is shown as a regular number string, but I'd like for it to display as MM:HH.

So '65' for example would display as 01:05 (one hour and 5 minutes).
Attachments
barchart.png
barchart.png (26.8 KiB) Viewed 414 times
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Minutes to HH:MM

Hi,

You can use tooltip.pointFormatter() callback function to change formatting. And to convert it from minutes to hours, you can use ready-made functions available on the Internet like the one in the demo.

Demo: https://jsfiddle.net/BlackLabel/eLo8kjc1/
API: https://api.highcharts.com/highcharts/t ... tFormatter

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Usage”