mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.27k stars 6.58k forks source link

Gantt chart with 'excludes' option extends events with absolute date range unexpectedly #2147

Open carbeer opened 3 years ago

carbeer commented 3 years ago

Describe the bug When creating a Gantt diagram with the option "excludes weekends", and specifying some event duration with start and end date, the resulting diagram will display a longer period than expected. It seems like the time range is internally converted to a number of days and then divided by 5 (due to excluded weekends) to compute the time range.

Other excludes options seem to produce bugs according to the same logic.

To Reproduce Steps to reproduce the behavior: Create a gantt diagram with option "excludes weekends" and specify an event time frame using dates.

Expected behavior An event lasting the specified time range (ignoring the excludes option).

Example and screenshot

gantt
  excludes weekends
  dateFormat DD.MM.YYYY

  section test
  too long :01.10.2021, 31.10.2021

image

Code sample in Live Editor

fbbln commented 2 years ago

This issue occurs only if the dateFormat option is used. If the input format (as specified by dateFormat) is left as default YYYY-mm-dd everything is shown correctly. As a workaround one can set "axisFormat %d.%m.%Y" to output dates correctly.

Shown correctly: gantt title Error Proof of Concept axisFormat %d.%m.%Y excludes weekends section Proof of concept task2 :a2,2022-10-15 , 2022-10-31

grafik