Is there any way to get the total duration of critical tasks

Hello,
I have some questions to ask.
1.Is there any way to get the total duration of critical tasks?
2.How do I get project_start after I set the project_end time?
3.I don’t want to change the constraint type when the schedule changes just to drive the start and end times

In the Project, I changed the project scheduling mode to Project FInish Date.
The constraint type of the task does not change, only the start and end times are driven.

But in the Gantt chart there would be no change

Found by research,I must set Project end and project start at the same time to achieve my expected effect.
But all I know is project_start date or project_end date.
Is there any way to get the total duration of critical tasks?
Let me get the project_start time when I only know the project_end time

This gif is what I was hoping to achieve

ggg

The code in this link is an example of failure and does not live up to my expectations

https://snippet.dhtmlx.com/g0aeu5e8

Also, as the tasks already have constraints, they stay at the same dates when I switch between the scheduling modes. So, I need to remove the asap and alap constraints to reschedule tasks to earlier or later dates. But, I don’t want to change the constraint type when the schedule changes just to drive the start and end times

look forward to your reply!
help me,plz

@ramil @ArtyomBorisevich

@ramil
@ArtyomBorisevich

hello ,
@ArtyomBorisevich
Can you help me?

Hello,

Is there any way to get the total duration of critical tasks?

I’m not sure that I understood your question. What do you mean by critical tasks in your case?

How do I get project_start after I set the project_end time?

If you want to save gantt.config.project_start one of the options is to save project_start value into a variable.
If you meant the start date of the project, which changes its dates after scheduling to backward planning. You can get the start date of the earliest subtask of the project by using getSubtaskDates method:
https://docs.dhtmlx.com/gantt/api__gantt_getsubtaskdates.html

Please check the example:
DHTMLX Snippet Tool ;

I don’t want to change the constraint type when the schedule changes just to drive the start and end times

Unfortunately, the Gantt employs a different logic for backward planning. When backward planning is enabled, tasks are scheduled to start as late as possible, assigning them the “As Late As Possible” (ALAP) constraint. If you move a task, it will then acquire a “Finish No Later Than” (FNLT) constraint.

When you dynamically change the forward/backward planning, tasks would stay at the same dates, due to constraints. So, one of the options is to remove the ASAP and ALAP constraints to reschedule tasks to earlier or later dates, with gantt.autoSchedule method.
But, I can’t suggest any workarounds to get the desired behavior.
Here is the email of the Sales team that you can use to ask for custom development service:
sales@dhtmlx.com

Hello,
thanks for your reply

Is there any way to get the total duration of critical tasks?

Sorry, is critical path,not critical tasks
1.Is there any way to get the total duration of critical path?

2.Can you tell me how the Gantt chart is driven when enables backward scheduling?

There’s this scene

There are some figures as follows.Please check the example:

https://snippet.dhtmlx.com/uta091zu

When backward scheduling is enabled,I expect to get such data.
But I don’t see any change in the Gantt chart

3.Is there any way to do that?

I expect to get such data.

data: { id: 11, text: ‘Project #1’, type: gantt.config.types.project, progress: 0.6, open: true,constraint_type: ‘alap’ },
{
id: 1,
text: ‘1’,
start_date: ‘24-04-2019’,
end_date: ‘24-04-2019’,
duration: ‘5’,
parent: ‘11’,
progress: 1,
open: true,
constraint_type: ‘asap’
},
],
links: []

When backward scheduling is enabled.How do I get the longest date and the latest date in the critical path and the total duration of the critical path? Calculates the combined duration of tasks nested in the cirtical path or calculates the combined start/end dates of tasks nested in the cirtical path

.

.

Hello Menglin,

Is there any way to get the total duration of critical path?

There is no built-in feature for that. You need to implement a custom solution by using the Gantt API and Javascript.

You can iterate tasks with the eachTask method:
https://docs.dhtmlx.com/gantt/api__gantt_eachtask.html

Then you can check if a task is critical with the isCriticalTask method:
https://docs.dhtmlx.com/gantt/api__gantt_iscriticaltask.html

Then you can save the task dates and get the minimal and maximal dates. This allows you to calculate the duration of the critical path.

Here is an example of how it can be implemented:
https://snippet.dhtmlx.com/d62ivor5


When backward scheduling is enabled.How do I get the longest date and the latest date in the critical path and the total duration of the critical path? Calculates the combined duration of tasks nested in the cirtical path or calculates the combined start/end dates of tasks nested in the cirtical path

Gantt doesn’t have a built-in feature for that. You need to implement a custom solution.
You can modify the example above to fit your needs. You can already get the latest date of the critical path in the snippet. But it is not clear to me what you mean by the longest date. If you want to get the longest task in the critical path, you can save the duration when you iterate tasks:

const startDates = [];
const endDates = [];
const maxDuration = 0;
gantt.eachTask(function (task) {
  if (gantt.isCriticalTask(task)) {
    startDates.push(+task.start_date)
    endDates.push(+task.end_date)
    if (task.duration > maxDuration){
      maxDuration = task.duration
    }
  }
})

Can you tell me how the Gantt chart is driven when enables backward scheduling

When you enable backward scheduling, Gantt auto-schedules tasks from the end date. And it starts from successors to predecessors.
If a task doesn’t have the constraint, Gantt assigns the ALAP constraint and moves the task to the latest date.
But if a task has the ASAP constraint, it stays on its dates because of the constraint type rules.

When you switch between the scheduling modes (forward and backward), Gantt doesn’t change the task constraints. You need to do that manually.

Here is the updated snippet that shows how to reschedule tasks by removing the constraint type when you change the scheduling mode:
https://snippet.dhtmlx.com/h2e2kdst

Thank you for your help,ramil