Elm-charts formatting of dates


I love the elm-charts package. Definitely the easiest charting module I have ever encountered.

I could not find any documentation on how to format the dates generated by the times function. Now they are in US format, I would love to format them differently. (day/month vs month/day)

Thanks for any pointers,


Hi @hansv! Thank you for your kind words :blush: I didn’t realize that there wasn’t a good example for editing time label formatting- thanks for letting me know! I’ll add one at my earliest convenience.

For basic formatting you can use the format attribute on the x or y labels in question (like in this example). It will give you the timestamp (in float, so you will likely need to round it) which you can format as you’d like. I like using the ryannhg/date-format package for this!

However, if you need more advanced formatting, where you’d like use some higher level information than just the timestamp (e.g. info relative to other labels such as whether this label just changed month or year etc.) you can do that too, just a little more tricky. I made you a little ellie with an example which I hope is helpful! The gist is that you need to use the generate API to produce Time's which holds all the info available for each timestamp. You can then create exactly the labels you’d like! This is not as elegant for midlevel needs as I’d like it to be right now, but I hope I’ll find a nice way to improve it in the future. In the meanwhile, thank you for your patience!

Let me know if you have any further questions!


Hi Terezka,

this was exactly the info I needed, thanks for going above and beyond in helping me out.

Have an excellent weekend,

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.