Premium support for our pure JavaScript UI components


Post by jit@flowit.dk »

Hi,

According to documentation (https://www.bryntum.com/docs/gantt/api/Gantt/model/TaskModel#start-and-end-dates) the endDate is not included in the calculation of duration. So 2022-06-27 to 2022-06-27 has a duration of 0 days. If we set duration to 1 then the endDate changes to 2022-06-28 which is not acceptable. The task starts and ends on the same day.

This is what we want

2022-06-27 - 2022-06-27 = duration 1 day
2022-06-27 - 2022-06-29 = duration 3 days

How do we achieve this? We can certainly add an extra day to endDate runtime and keep the real endDate in the database. But we can't have a task that is scheduled for just one day (2022-06-27 - 2022-06-27) to be displayed as spanning two days (2022-06-27 - 2022-06-28) in the user interface.

What are our options ?

-- Thanks

Best regards
Jimmy Thomsen


Post by marcio »

Hey Jimmy,

For that, you'll need to work with the date and time for achieving that, check it here - https://www.bryntum.com/examples/gantt/aggregation-column/

If you run in the console, just as an example

window.gantt.taskStore.records[2].endDate = new Date('2019-01-14 23:59:59')

You'll see that the duration will be 1 day, as it's not the default behavior, that's a possible workaround.

Best regards,
Márcio


Post by jit@flowit.dk »

Thank you, Márcio.

The approach you suggest goes against the recommendation in the documentation which says: "A task which starts at 2020/07/18 and has 2 days duration, should have the end date: 2020/07/20, NOT 2018/07/19 23:59:59".

It's fine if you are sure we can rely on this work around. But I would be a bit displeased if it breaks in the future if we can't actually rely on this behaviour being maintained.

Furthermore if we have a task where duration is set explicitly, the endDate gets rounded up:
startDate: "2020-03-19",
endDate: "2020-03-19 23:59:59",
duration: 1 // This causes endDate to be rounded up to 2020-03-20 in the UI

Naturally we can just refrain from declaring duration explicitly, but that introduces a new problem: duration becomes a decimal since endDate-startDate is now less than X whole days. We can probably work around this by declaring a cell renderer which takes care of rounding.

Next, we have a problem when changing endDate. Duration becomes 1 day less than intended.
The same goes for duration when changing that - endDate becomes 1 day more than intended.
Naturally that too can be handled by custom renderers that subtracts the extra day, but then we have the same problem with the edit control which displays a value +/- 1 day off, compared to the rendered value.

Just to recap, this is what we want without hacking gantt:
2022-06-27 - 2022-06-27 = duration 1 day
2022-06-27 - 2022-06-29 = duration 3 days

Be aware that we show Start Date, End Date and Duration, so we need an approach that supports the visibility of all three.

Last edited by jit@flowit.dk on Fri Oct 07, 2022 11:38 am, edited 3 times in total.

Best regards
Jimmy Thomsen


Post by alex.l »

Hi jit@flowit.dk,

Documentation just explains simple math:
2020-10-10 00:00:00 + 1 day (24 hours) will be equal to 2020-10-11 00:00:00 and finish in next day, not in same day 59:59:59

2020-10-10 00:00:00 + 2 days (48 hours) will be equal to 2020-10-12 00:00:00.
etc.

If you will use calendars for your tasks and set working day hours as 8 hours and not 24 hours, it will be possible to have same day for 1 day duration tasks.
Please check docs about calendars: https://bryntum.com/docs/gantt/guide/Gantt/basics/calendars
And check ProjectModel properties such as
https://bryntum.com/docs/gantt/api/Gantt/model/ProjectModel#field-hoursPerDay
https://bryntum.com/docs/gantt/api/Gantt/model/ProjectModel#field-daysPerWeek
https://bryntum.com/docs/gantt/api/Gantt/model/ProjectModel#field-daysPerMonth

All the best,
Alex


Post by jit@flowit.dk »

Hi Alex.

Thanks for the suggestion. Unfortunately it does not work as requested.

We don't care about hours in a day. We care about dates. Nothing else.

Consider the following example:
Start Date = 2022-01-18
End Date = 2022-01-18

We want this to have a duration of 1 day.

If we change Duration to 3, then End Date must become 2022-01-20.
If we instead change End Date to 2022-01-20 then Duration must become 3.

We don't want Gantt to take hours into account. How can we achieve that?

Best regards
Jimmy Thomsen


Post by alex.l »

I've opened https://bryntum.com/examples/gantt/advanced/
dbl clicked on a task, changed duration to 1 day. Saved. I see correct dates.
dbl clicked again, changed duration to 3 days, saved. Still all correct to me.
Same result if I edited endDate instead of duration.

Please try yourself and provide clear steps to reproduce.
If it's not reproducible in our example, please check your calendar settings, as I suggested above.
If no luck, please send us runnable test case with steps to reproduce, including JSON data sample, with project settings and calendars.

All the best,
Alex


Post by jit@flowit.dk »

See attached video.

Attachments
Untitled.m4v
(21.89 MiB) Downloaded 29 times

Best regards
Jimmy Thomsen


Post by arcady »

So 2022-06-27 to 2022-06-27 has a duration of 0 days. If we set duration to 1 then the endDate changes to 2022-06-28 which is not acceptable.

Using 8hrs/day calendar could be what you need.
You can try that on the advanced demo online here. Just execute this code in your browser console and then try editing tasks:

gantt.project.hoursPerDay = 8
gantt.project.calendar = 'business'

Post Reply