Our state of the art Gantt chart


Post by rgauthier »

Hello!

We are running in to strange issue when trying to implement baselines

Due to a few differences between our requirements and library behaviour (primarily https://github.com/bryntum/support/issues/9643) we have disabled Bryntum's calculations and are managing everything ourselves server-side

overriding-calculations.png
overriding-calculations.png (49.91 KiB) Viewed 204 times

This has been working ok so far, but now we are implementing baselines. We have autoSync enabled and the FE code is lifted from the baselines demo. Without making any other changes from load, if I "Set Baseline 1", the PATCH request is rounding (?) the decimal baseline values

set-baseline-duration-change.png
set-baseline-duration-change.png (194.21 KiB) Viewed 204 times

I can not reproduce this in the demo, but it does not have autoSync enabled and is of course using the Bryntum logic for the calculations. If I check gantt.project.changes in the demo, even those with decimal durations seem to be persisted correctly. I am at a loss for how to get around this issue.

I have been debugging the Bryntum code and this is where I am so far (please help 😅)
I believe it is coming from this "createRecord" function, you can see the task on the data param has duration 71.5 but the resulting return value has duration 72.

bryntum-create-record-changing-duration.png
bryntum-create-record-changing-duration.png (107.37 KiB) Viewed 204 times

I'm sure this is an oft-used function, but we have not run into this issue when editing any values in the grid or with gantt bar interaction, seems to be specific to setting baselines?


Post by arcady »

Hello,

It's hard to tell something without a test case.
Try setting a breakpoint in Baseline duration setter to catch the moment a value gets rounded:

class MyBaseline extends Baseline {

    get duration() {
        return super.duration;
    }

    set duration(value) {
        debugger
        super.duration = value;
    }
}

class MyTask extends TaskModel {

    static get fields() {
        return [
            { name : 'baselines', modelClass : MyBaseline }
        ]
    }
}

new Gantt({
    project : {
        // Let the Project know we want to use our custom MyTask model
        taskModelClass     : MyTask,
        ...

Best regards,
Arcady


Post by rgauthier »

I will try to debug more later today, but actually I think I can reproduce a very similar issue in the demo.

Looking at the demo behaviour, the primary difference between what I see there and what happens in my application is I don't have to change any values, I get the issue even if I just load the initial data and immediately try to set a baseline. Perhaps this is because we can't disable the calculations until after the gantt has been initialized with the dataset. My assumption was rounding, but what's happening in the demo seems to be that it's not taking the updated value for the baseline (the duration on load for task 11 is 3)

https://bryntum.com/products/gantt/examples/baselines/

baselines-demo-duration-issue.png
baselines-demo-duration-issue.png (264.2 KiB) Viewed 180 times

Post by alex.l »

Thank you for the report and clear steps to repro, looks like it's a bug. Here is a ticket https://github.com/bryntum/support/issues/11345
You can subscribe on ticket updates to be notified when it's done.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by rgauthier »

Hey Alex, thanks for the reply. I'll follow the ticket!


Post by alex.l »

Hi rgauthier,

I've closed the ticket with a comment. Please review reply, it should help you to go forward.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by rgauthier »

Hey Alex, thanks but I don't understand the reply.

My expectation of how baselines should work is take a snapshot of the existing data...as you can clearly see in the screenshot the grid says Duration 3.2 and the baseline is being set to 3.

If I skip the commit step in the reproduction steps above and look at the changes all at once, you can see the project data does recognize that the duration has changed (it would send the new duration through the sync) but even though the duration was changed before I "Set baseline 1" the duration values for the main data and the baseline don't match.

baseline-duration-is-calculated-even-though-calculations-are-disabled.png
baseline-duration-is-calculated-even-though-calculations-are-disabled.png (197.62 KiB) Viewed 117 times

The point for us of disabling the calculations is we just want Bryntum to display the data as provided--if startDate+duration does not equal endDate according to your logic, with the calculations disabled I would still expect the tool to send the data in the baseline to match what is in the grid.

If the calculations are disabled, my feeling is it should send the duration value directly instead of trying to calculate it based on start/end date.


Post by alex.l »

The data is not consistent, since endDate - startDate = 3 days, but duration = 3.2 days. What is correct value to take into account?
In case you disabled calculations, take care of sync data in event record, in that case there won't be any conflicts what should be taken into account for a baseline - endDate or duration.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by rgauthier »

What is correct value to take into account?

From my point of view, if the calculations are disabled it should take all data as is and PATCH it through, whether the Bryntum calculations would consider it consistent or not. Since the calculations are disabled, I wouldn't expect baselines to be calculating the duration based on start and end date--which must be where it is getting duration = 3 from right? because duration is not set to 3

We will have to manage it on our end I guess, by picking through the data that is sent in the PATCH. In my view this is a bug though. The baselines data being sent through should be consistent with the current UI and with the project data (if I getById('11'), the duration is clearly set to 3.2!)


Post by arcady »

Hello,

Task calculations are disabled in the Engine. But Baseline though is a separate model not served by the Engine. So when you call task.setBaseline(...) the task puts its values into a baseline. And the values get normalized. Baselines tend to use dates primarily so duration gets recalculated based on them.

You can override task store setBaseline if you want a custom logic. The method is rather short and simple.

Best regards,
Arcady


Post Reply