adds a calendar into Gantt
calendar | CalendarConfig | an object with configuration of the calendar |
string | the id of the calendar |
// adding a previously created calendar
var calendarId = gantt.addCalendar(calendar);
// adding a calendar with a new config
var calendarId = gantt.addCalendar({
id:"custom", // optional
worktime: {
hours: ["8:00-17:00"],
days: [ 1, 1, 1, 1, 1, 1 ,1]
}
});
var calendar = gantt.getCalendar(calendarId);
The calendar configuration object can contain the following attributes:
Instead of the number of a week day, you can also set custom working hours for this day.
For example:
var calendar = {
id:"calendar1", // optional
worktime: {
hours: ["8:00-17:00"],
days: [ 0, 1, 1, 1, ["12:00-17:00"], 1, 0]
}
}
where ["12:00-17:00"] are working hours from 12 pm to 17 pm for Thursday.
There is the ability to configure different working time rules for different periods of time by using the customWeeks attribute:
// adding a calendar with a new config
gantt.addCalendar({
id:"default", // optional
worktime: {
hours: ["8:00-17:00"],
days: [ 1, 1, 1, 1, 1, 1 ,1],
customWeeks: {
winter: {
from: new Date(2020, 11, 1),// December 1st, 2020
to: new Date(2021, 2, 1),// March 1st 00:00, 2021
hours: ["9:00-13:00", "14:00-16:00"],
days: [ 1, 1, 1, 1, 0, 0, 0]
}
}
}
});