Our state of the art Gantt chart


Post by richhunter »

Hi,

I have a need to extract the name of each calendar interval that is used by a task.

We plan to link data from associated to the task directly to another set of data that drives calendar intervals. These intervals are fairly dynamic and can be user defined.

This does not have to be real time/per change, I would be happy for it to be triggered by button press, etc.

For example I have data structure:

Tasks:
Task 1,
Task 2

Calendar 1:
Interval 1: Name: some day
Interval 2: Name: another day
Interval 3: Name: third day

Calendar 2:
Interval 4: Name: other cal day

Task 1 is allocated interval 1 and 2
Task 2 is allocated interval 1, 3, and 4

My output would be:

Task: 1
Interval: Cal 1, some Day
Interval: Cal 1, another Day

Task: 2
Interval: Cal 1, some Day
Interval: Cal 1, third Day
Interval: Cal 2, other cal day


Post by alex.l »

Hi richhunter,

Each task has https://bryntum.com/docs/gantt/api/Gantt/model/TaskModel#field-calendar field that returns assigned calendar if available, and https://bryntum.com/docs/gantt/api/Gantt/model/TaskModel#field-effectiveCalendar that returns an effective calendar, even if task has no calendar directly applied.
Each calendar has https://bryntum.com/docs/gantt/api/Gantt/model/CalendarModel#field-intervals field that contains an array of https://bryntum.com/docs/gantt/api/SchedulerPro/model/CalendarIntervalModel

That should be enough to collect the information you need.

All the best,
Alex


Post by richhunter »

Hi Alex, thanks for the response.

While I can get the assigned calendar and all intervals this way, I cannot get the actual sub-list of intervals used when scheduling the task.

For example, my calendar has 10 intervals altogether. Using the suggested approach will just show all 10 intervals rather than, say, the 1st 2 intervals which were used to schedule the task.

Each interval in my calendar will have a unique name and I need to be able to get the name of the specific intervals that were used when scheduling the task.


Post by alex.l »

How do you use only few intervals from an active calendar to schedule the task?

All the best,
Alex


Post by richhunter »

Apologies, I may not be explaining myself well.

Our goal is to use the Gantt and Calendars to help with planning schedules of work.

For example, a schedule of work may be 'build a bridge'

This will comprise of many tasks allocated x number of days to complete.

For example, a task of 'prepare the ground work' is assigned 1 day. (we define 1 day = 24 in the project settings)

Separately, our system allows users to build the available access times for the bridges works. For example, the client agrees that 'every Tue, Wed, and Thu night in June between 00:00 and 06:00 is available to access the network.

This is what creates our calendar, so for the above rule, the calendar for June 2022 has 14 intervals.

When we apply that calendar ruleset to the task, it will correctly select the intervals....

1st June 00:00-06:00,
2nd June 00:00-06:00,
7th June 00:00-06:00,
8th June 00:00-06:00

This totals 24 hours/1 day as expected. Elsewhere in the system, we would want to show to the client that 'ok, based on the rules you gave us, these are the days we are going to be doing the work' (we plan to do some additional data assignment at this point outside the Gantt)

This all works, the only thing I having trouble with is actually getting the list of those 4 intervals programmatically, currently your Gantt/scheduler just does the logic without exposing it.

I hope this helps explain my problem.


Post by alex.l »

There is a method in calendar instance getWorkingTimeRanges(startDate, endDate). It will be documented in next release, now it's not available in docs.

Returns working time ranges between the 2 dates.

const { startDate, endDate } = task;
const intervals = calendar.getWorkingTimeRanges(startDate, endDate);
// intervals is an array of objects with properties: 
// startDate - start date of interval, 
// endDate - end date of interval, 
// name - name of interval.

I hope now I got your question correct.

All the best,
Alex


Post by richhunter »

Perfect, that is exactly what I needed, tested and working.

Thanks for the prompt replies!


Post Reply