Our state of the art Gantt chart


Post by jasonlunsford »

Hey Team,

Hopefully an easy question. We would like to see the Gantt Project Date start flag move BACK automatically when the user moves a task passed the flag (basically the same behavior as the Project End flag when the user moves a task passed that flag). For reference here's the situation:

Screen Shot 2024-03-04 at 09.55.09.png
Screen Shot 2024-03-04 at 09.55.09.png (62.71 KiB) Viewed 178 times

So in this scenario we would expect to see the Project Start flag move back automatically.

How do we configure Gantt to do this?

Thanks!


Post by jasonlunsford »

Quick update. Business made an about face on this feature. They are now requesting the following:

1) DO NOT ALLOW users to move tasks "passed" the Project start flag. How can I PREVENT the user from moving tasks EARLIER that the project start date?

2) How can I set my Project Start / End date INDEPENDENT of the start/end dates of my individual tasks? I tried passing start/end dates to my ganttConfig file but it seems that they are ignored in favor of the tasks.

3) DO NOT MOVE the Project End if the user pushes a task "passed" the Project End flag. We need to be able to see if a task exceeds a project's end date. How do I fix the Project End date so it doesn't "float back" if the user advances a task along?

Thank you!


Post by marcio »

Hey jasonlunsford,

Thanks for reaching out.

Regarding the first post, there is no built-in option to automatically change the project start date.

We have https://bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-projectConstraintResolution that you can see a live example here of how it works https://bryntum.com/products/gantt/examples/advanced/

The idea of forward-scheduled projects is to calculate the end date based on the task's disposition and constraints. So you'll need to handle that special rule in your code, perhaps using https://bryntum.com/products/gantt/docs/api/Core/data/Store#event-beforeUpdate and checking the end date of the task with the end date of the project, and then returning false if needed.

Best regards,
Márcio


Post by jasonlunsford »

That's a good idea Marcio, I'll do that to prevent users moving tasks passed the Project End flag.

What about my other points?

Thanks man!


Post by marcio »

Hey,

Regarding 1, we have https://bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-projectConstraintResolution

Regarding 2, how did you set up the start/end dates of the project? Did you set the dates for the project model?

Best regards,
Márcio


Post by jasonlunsford »

marcio wrote: Mon Mar 04, 2024 10:14 pm

Hey,

Regarding 1, we have https://bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-projectConstraintResolution

Regarding 2, how did you set up the start/end dates of the project? Did you set the dates for the project model?

Cool, I'll try "projectConstraintResolution"!

I passed my projectStartDate and projectEndDate to the model, like this:

            <BryntumGanttProjectModel
              tasks={tasks}
              ref={ganttProjectRef}
              taskModelClass={TimelineModel}
              onDataReady={handleOnDataReady}
              startDate={projectStartDate}
              endDate={projectEndDate}
            />

When I do it like this the project start flag appears correctly, but the project end flag STILL "falls back" to the task with the most recent end date instead of "sticking" to the project end date. That's really the last mystery we need to solve here.


Post by jasonlunsford »

Hi Marcio,

"projectConstraintResolution" didn't seem to have an effect. Which is fine, i'm using "onBeforeTaskDropFinalize" to handle validation and that seems to work well. We just need to figure out how to make the Project End flag "stick" to the actual project end date and we'll be good.


Post by arcady »

Hello,

A forward-scheduled project concept is - all tasks are scheduled ASAP by default.
Such projects have fixed start date based on which their tasks dates are calculated. End dates of such projects are calculated by start dates are fixed (meant to be provided manually).
So it's not possible to auto-calculate the project start date since it will result a calculation cycle: calculate task date based the project start date -> calculate the project start date based on its children dates -> ..

You could override ProjectLines feature to change the start line position.
Here is an example of making a custom feature based subclassing standard ProjectLines:

// Make a custom feature based on ProjectLines
class MyProjectLines extends ProjectLines {

    static $name = 'MyProjectLines';

    // override timeRanges getter to provide another set of line dates
    get timeRanges() {
        const { project } = this.client;

        // If project is set and got tasks
        if (project?.childEvents) {
            const
                { startDate, endDate } = project,
                toProcess = [...project.childEvents];

            let
                // use project startDate initially
                minProjectDate = startDate,
                child;

            // Iterate project tasks and find minimum task date
            while ((child = toProcess.shift())) {
                const childDate = child.startDate || child.endDate;

                if (childDate && childDate < minProjectDate) minProjectDate = childDate;

                if (child.children) {
                    toProcess.push(...child.children);
                }
            }

            return minProjectDate && endDate ? [
                {
                    name      : this.L('L{Project Start}'),
                    startDate : minProjectDate
                },
                {
                    name      : this.L('L{Project End}'),
                    startDate : endDate
                }
            ] : [];
        }

        return [];
    }

}

// register the custom feature
GridFeatureManager.registerFeature(MyProjectLines, true, 'Gantt');

const gantt = new Gantt({
    ...
    features : {
        // disable standard feature
        projectLines : false,
        // enable our custom feature instaed
        myProjectLines : true,
        ...

Best regards,
Arcady


Post by jasonlunsford »

HI Arcady,

First of all THANK YOU for the extremely useful and helpful code for creating a custom Project Line. I'll add this to my reference sheet for future use. However, what I want is merely a way to set the "Project end" ProjectLine to be positioned at the end of the project, NOT at the end of the latest task. Does that make sense? So if my project ends on March 31, 2023, that's where the ProjectLine "Project end" should be placed, independent of whatever the tasks themselves are doing.

Again, you can see here how I'm setting project end date, but for some reason it is not doing what I would expect:

        <BryntumGanttProjectModel
              tasks={tasks}
              ref={ganttProjectRef}
              taskModelClass={TimelineModel}
              onDataReady={handleOnDataReady}
              startDate={projectStartDate}
              endDate={projectEndDate}
         />

Post by alex.l »

Hi,

Does that make sense?

Arcady tried to explain how it works, I will try to re-phrase s bit. Forward scheduled projects has start date that you set manually, but end date is calculated according to tasks provided. That's the main goal Scheduling Engine - schedule all tasks and get end date as a result.
Backward scheduled projects has manual/fixed end date, and start date will be calculated automatically.
For other behaviour you'll need to override classes, as Arcady suggested to you.

All the best,
Alex


Post Reply