Introduction

A calendar is an extension of an activity repository with the addition of a name and a visibility property. Calendars can be added to the whole Gantt chart or to individual rows within the Gantt chart. Also the Dateline makes use of them.

Calendar Support
const graphicsCalendars = this.gantt.getGraphics().getCalendars();                        // Get calendars attached to the Gantt.
const rowsCalendars = this.gantt.getGraphics().getRows().map(row => row.getCalendars());  // Get calendars attached to the Rows.
const datelineCalendars = this.gantt.getDateline().getCalendars();                        // Get calendars dateline to the Dateline.

Calendars are used for the background of rows. They can mark things like weekend days or holidays. Calendar information is always shown as read-only. Activities returned by calendars have to be of type CalendarActivity. They can not be edited interactively by the user. 

Weekend Calendar

There already is a predefined calendar type included in ScheduleJS. It is called WeekendCalendar and it is used to mark the weekend days (e.g. Saturday, Sunday).

The WeekendCalendar is included as a default calendar in the DefaultScheduleGantComponentBase.

Drop default Calendars
import {DayOfWeek} from "@js-joda/core";
// ...
const calendars = this.gantt.getCalendars();
this.gantt.getCalendars().splice(0, calendars.length); // Drop default calendars.
    
const newWeekendCalendar = new WeekendCalendar();                       // Create a new calendar.
newWeekendCalendar.setWeekendDays(DayOfWeek.MONDAY, DayOfWeek.TUESDAY); // Set weekend days as Monday and Tuesday.
calendars.push(newWeekendCalendar);                                     // Register the new calendar.


Replace existing WeekendCalendar
const ganttCalendarsList = this.gantt.getCalendars();
const actualWeekendCalendars = this.gantt.getCalendars().find(it => it instanceof WeekendCalendar);
ganttCalendarsList.splice(ganttCalendarsList.indexOf(actualWeekendCalendars), 1);
const newWeekendCalendar = new WeekendCalendar();
newWeekendCalendar.setWeekendDays(DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY);
this.gantt.getCalendars().push(newWeekendCalendar);