mermaid-gitbook icon indicating copy to clipboard operation
mermaid-gitbook copied to clipboard

Feature Request - Format Date/Time Output

Open Heiko-san opened this issue 5 years ago • 3 comments

Actually you can perfectly use the gantt diagram to draw tasks on hours, minutes or even seconds base. This could make mermaid a powerful tool to easily visualize time trackings (like visualize a taskwarrior database).

https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2FudHRcbnRpdGxlIFRpbWUgVHJhY2tpbmdcbmRhdGVGb3JtYXQgIEhIOm06c1xuc2VjdGlvbiBNb25kYXlcbkEgdGFzayAgICAgICAgICAgOiBhMSwgMDk6MDA6MDAsIDA5OjMwOjAwXG5Bbm90aGVyIHRhc2sgICAgIDphZnRlciBhMSAgLCAyMG1cbnNlY3Rpb24gVHVlc2RheVxuVGFzayBpbiBzZWMgICAgICA6MDk6MDA6MzAgICwgMTJtXG5hbm90aGVyIHRhc2sgICAgICA6IDI0bSIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In19

However the scale at the bottom still only prints the date.

It would be helpful if the dateFormat field would be evaluated for the date/time output aswell, or if you had another outputFormat field for that.

Heiko-san avatar Jun 19 '19 19:06 Heiko-san

This would be really helpful - with longer gantts with a mix of long and short tasks, the bottom scale is unreadable. A separate field would be great so we can specify year-month-date as start/ends but show month-date on the output.

justinrush avatar May 06 '20 18:05 justinrush

It's not in the docs, but axisFormat ended up solving this for me. It uses a different formatting to dateFormat, as explained under "Scale" here: https://mermaid-js.github.io/mermaid/#/gantt?id=scale

Example:

gantt
    dateFormat   YYYY-MM-DD
    axisFormat   %b %Y

kut avatar May 12 '20 21:05 kut

@kut Here's a full example using axisFormat to solve the problem:

arvidj avatar Apr 05 '24 07:04 arvidj