Resource Calendar Creation Takes Too Long

I have 600 resources and 10 years of calendar data. In the Gantt, I am creating calendars for each resource. But each calendar will take ~2s to create and I have many resources. Is there any faster way for this one? The calendar for each resource is unique and it is set per day. Maybe there is a way to initialize in the addcalendar the array of days?

resourceWorkTimeData.forEach((resourceWorkTime) => {
      const calendarId = gantt.addCalendar({ id: resourceWorkTime.resourceId });
      const calendar = gantt.getCalendar(calendarId);

      //Set the default work time for all days to non-working day
      for (let day = 0; day < 7; day++) {
        calendar.setWorkTime({ day, hours: [GANTT_NONWORKING] });
      }

      resourceWorkTime.workTime.forEach((workTime) => {
        const workHours = workTime.shiftHours;
        const date = new Date(workTime.year, workTime.month - 1, workTime.day);

        if (workHours && workHours.length > 0) {
          calendar.setWorkTime({ date: date, hours: workHours });
        }
      });
    });

Hello,
Unfortunately, at the moment there’s no way to pass an array of dates directly into the addCalendar method.
However, we are planning to introduce this feature in a future. The initial idea is to allow configuration like this:

{
	id: "global",
	hours: ["8:00-12:00", "13:00-17:00"], // global work hours for weekdays
	days: {
		weekdays: {
			0: false, // 0 = Sunday, 6 = Saturday
			1: true,
			...
		},
		dates: {
			"2025-04-06": true,               // use global hours
			"2025-04-08": false,              // non-working day
			"2025-04-09": ["9:00-15:00"]      // custom hours for this date
		}
	}
}

I’ll keep you updated as soon as there’s any progress.

Hello,

It’s okay now. I managed to make it work using the customWeeks. I set the from and to on the same day with key for each day.

1 Like