Total Slack and Free Slack(gantt.getTotalSlack(task) and gantt.getFreeSlack(task))

Hello everyone.

It seems gantt.getTotalSlack(task) and gantt.getFreeSlack(task) are alwayse using Gantt default/global calendar to calculate the slacks.

For example,

  1. Gantt Default/global calendar is a 24 hours calendar
  2. The task is assigned with dayshift calendar(8 hours a day from 9am to 5pm) and the task end datetime is 5pm of 5th of March
  3. The project end date time is 5pm of 6th of March

In this case, I think the correct total/free slack should be 8/8 hours, but gantt.getTotalSlack(task) and gantt.getFreeSlack(task) would give the result of 24/24 hours as its using project default/global calendar to do the calculation instead of use task assigned calendar(day shift calendar).

So wonderng if anyone know a easy wrok around or if the fix is in next release.

Hello Qianhao,
If you don’t enable the work_time parameter, it is expected that the critical path doesn’t use the work time settings.
You need to enable the work_time parameter and set the calendar_id: "fulltime" parameter for the tasks that you want to use the 24-hour calendar.

Also, the critical path calculation is usually working with auto-scheduling. And in that case, Gantt auto-schedules tasks even if they have different calendars.
If auto-scheduling is turned off, the free and total slacks should not take successors into account as they cannot move them to the future date. Successors can be affected only when auto-scheduling is enabled.

You can check how it works in the following snippet:
https://snippet.dhtmlx.com/bhfvfysb

Hi Ramil

I dont think I have explained my problem well

I have replicated it in the following snippet - https://snippet.dhtmlx.com/at6i75it

if you look at ‘Task #3’, gantt.getFreeSlack(targetTask) and gantt.getTotalSlack(targetTask) shows the free/total slack are 5/5, but becasue I have assigned fulltime calendar to ‘Task #3’, are they should be 17/17 hours?

Maybe I have misunderstood how gantt total and free slack works, but I think in MsProject, it will calculate the free and total slack based on task assigned calendar, but it seems in the sinppet, it still using the gantt default calendar.

Hello Qianhao,
Thank you for the clarification and sharing the snippet. Yes, that seems to be a bug in Gantt. If the tasks Project #1 and Task #3 are linked, Gantt calculates the slack correctly. But when Task #3 doesn’t have successors, Gantt uses the global calendar to define the slack.

I updated the snippet to make it clearer:
https://snippet.dhtmlx.com/vkxe2bvc

I added it as a bug to your internal bug tracker. The dev team will fix it in the future, but I cannot give you any ETA.