Search code examples
asp.netgoogle-visualizationgantt-chart

Gantt Chart Duration Calculation is incorrect


All,

We're using Google Gantt chart in our project management software to display scheduled tasks. The problem is that when a task begins, for ex: on Sep 21 and ends on Sep 21, the gantt chart calculates this to have a duration of 0 days which in the context of scheduling is incorrect. A day still has 24 hours and this task has a duration of 1 days. Obviously, this causes the task's visual bar not to render.

As a workaround, I decided to calculate the duration myself, ie. I specified in my json start/end dates and duration but the gantt chart ignores my duration and simply subtracts the dates and returns 0 days for the duration. This is weird because the documentation says otherwise (from docs: If start/end/duration all present - Check that duration is consistent with start/end times. Throws error if inconsistent.)

You might say, why I don't add +1 day to end date,- yes that will fix the duration calculation but now the displayed end date in tooltip will be interpreted wrong by the user (the bar lengths do render correctly). The end date is assumed to be (12 am) but that's not displayed so the user may assume actual day which ends on (23:59:59 PM).

At the minimum the Gantt chart should allow me to override the duration. In the future, I think it would be great if the Gantt chart supported date/time or would handle the calculations in 2 different ways (or modes if you like).

Any suggestions would be appreciated.

Thanks,

lk


Solution

  • For the time being I went with this solution:

    Overall, the Gantt chart works correctly. In a situation where the task start/ends on the same day I simply decided to add +1 day to the end date and it renders correctly on the time line. The only thing that is confusing to our users is the display of the date range in the tooltip (which goes for a single day, for ex: sep 30 - oct 1, instead of what's displayed in our system sep 30 - sep 30). This issue can be resolved if time was added to the Gantt chart then I could add +1 day and subtract -1 sec. Rendering would be more accurate and displayed date range would be correct.

    I have the option to replace the tooltip but I am hoping google team will add time component to the Gantt chart.