AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.gantt.Calendar Improve this Doc

Extends: anychart.core.Base

Gantt calendar class.
Used to take a working time, weekends and holidays settings and make necessary calculations to provide it to user and to Gantt Chart to be displayed visually.

Methods Overview

Specific settings
holidays()Getter for user defined holidays.
schedule()Getter for user defined daily schedule.
Miscellaneous
getWorkingSchedule()Gets detailed calculated working schedule considering parameters passed and current schedule and holidays settings.

Methods Description

getWorkingSchedule

Gets detailed calculated working schedule considering parameters passed and current schedule and holidays settings.

Returns:

Array.<anychart.core.gantt.Calendar.DailyScheduleData> - Array of objects containing daily schedule data (see anychart.core.gantt.Calendar.DailyScheduleData fields description).

holidays

Getter for user defined holidays.

Returns:

Array.<(anychart.core.gantt.Calendar.Holiday|null)> | null - Current holidays or null if holidays is not specified.
See listing
var scale = ganttChart.xScale();
var calendar = scale.calendar();
var schedule = calendar.holidays();
Setter for user defined holidays. This method sets exact-date or yearly holidays.
Must be an array of objects defined as anychart.core.gantt.Calendar.Holiday.
See anychart.core.gantt.Calendar.Holiday type definition description and code example below.

NOTE:
- Holidays will be visible (see anychart.core.ui.Timeline#holidaysFill) only if gantt timeline is zoomed to days.
- Also, if holiday is visible and overlaps the weekend, holiday drawing is preferred.
- Holiday (anychart.core.ui.Timeline#holidaysFill) will not be visible if gantt timeline is zoomed to hours or below. Working hours (anychart.core.ui.Timeline#workingFill) and not working hours (anychart.core.ui.Timeline#notWorkingFill) will be visible instead, because holiday can contain working hours.

Params:

NameTypeDescription
holidaysArray.<(anychart.core.gantt.Calendar.Holiday)>User defined holidays.

Returns:

anychart.core.gantt.Calendar - Self instance for method chaining.
See listing
var scale = ganttChart.xScale();
var calendar = scale.calendar();
calendar.holidays([
  { day: 4, month: 6, label: 'Yearly holiday (year is not specified)'}, // 4th of July, yearly.
  { day: 12, month: 3, year: 2020, label: 'Easter (year is specified)'} // 20th of April, 2020.
]);

schedule

Getter for user defined daily schedule.

Returns:

Array.<(anychart.core.gantt.Calendar.DailyWorkingSchedule|null)> | null - Current daily schedule or null if schedule is not specified.
See listing
var scale = ganttChart.xScale();
var calendar = scale.calendar();
var schedule = calendar.schedule();
Setter for user defined daily working schedule. This method sets weekly working days, weekends and working time.
Must be an array of 7 objects defined as anychart.core.gantt.Calendar.DailyWorkingSchedule or null-values.
null-value in this case means a weekend-day.
First element of this array as Sunday, last one is Saturday.

NOTE:
- Weekends will be visible (see anychart.core.ui.Timeline#weekendsFill) only if gantt timeline is zoomed to days or below.
- Working hours (anychart.core.ui.Timeline#workingFill) and not working hours (anychart.core.ui.Timeline#notWorkingFill) will be visible if gantt timeline is zoomed to hours or below.

Params:

NameTypeDescription
scheduleArray.<(anychart.core.gantt.Calendar.DailyWorkingSchedule|null)>User defined working schedule.

Returns:

anychart.core.gantt.Calendar - Self instance for method chaining.
See listing
var scale = ganttChart.xScale();
var calendar = scale.calendar();
// 0-element (Sun) is a weekend, 6-element (Sat) is weekend as well. All another days are working
// from 10 a.m. to 6 p.m.
calendar.schedule([
  null,                 // Sun
  { from: 10, to: 18 }, // Mon
  { from: 10, to: 18 }, // Tue
  { from: 10, to: 18 }, // Wed
  { from: 10, to: 18 }, // Thu
  { from: 10, to: 18 }, // Fri
  null                  // Sat
]);