Top
You are looking at an outdated 7.12.0 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.scales.Calendar Improve this Doc

Extends: anychart.core.Base

Calendar scale. Note: To create instance use anychart.scales#calendar method.

Methods Overview

Special
availabilities()Availabilities settings.
getWorkingSchedule()Getter for the working time in passed datetime interval.
timezoneOffset()Timezone offset settings.
weekendRange()Settings for regular weekend days.

Methods Description

availabilities

Getter for the availabilities for the calendar.

Returns:

Array.<anychart.scales.Calendar.Availability> - The current availabilities.
Setter for the availabilities for the calendar.

Params:

Name Type Description
value Array.<anychart.scales.Calendar.Availability> Array of availabilities. Next availability has more priority than previous.

Returns:

anychart.scales.Calendar - Self instance for method chaining.
Sets weekends
var calendar = anychart.scales.calendar();
calendar.availabilities([
  {each:'day', from: '10:00', to: '18:00'},
  {each:'day', from: '14:00', to: '15:00', isWorking: false}
]);

getWorkingSchedule

Getter for the working time in passed datetime interval.

Params:

Name Type Description
startDate number Start date in UTC format.
endDate number End date in UTC format.

Returns:

Array.<Array.<Array.<number>>> - An array of arrays of tuples.
Getting wokring time
var calendar = anychart.scales.calendar();
calendar.availabilities([
  {each:'day', from: '10:00', to: '18:00'},
  {each:'day', from: '14:00', to: '15:00', isWorking: false}
]);
var getWorkingTime =  calendar.getWorkingSchedule(Date.UTC(2016, 0, 31), Date.UTC(2016, 1, 1));
// [
//  [
//    [Date.UTC(2016, 0, 31,10), Date.UTC(2016, 0, 31,14)],
//    [Date.UTC(2016, 0, 31,15), Date.UTC(2016, 0, 31,18)]
//  ],[
//    [Date.UTC(2016, 1, 1,10), Date.UTC(2016, 1, 1,14)],
//    [Date.UTC(2016, 1, 1,15), Date.UTC(2016, 1, 1,18)]
// ]

timezoneOffset

Getter for the timezone offset.

Returns:

Array.<number> - The current timezone offset in minutes.
Setter for the timezone offset for the output availabilities.

Params:

Name Type Description
var_value Number Offset in minutes.

Returns:

anychart.scales.Calendar - Self instance for method chaining.
Sets timezone offset
var calendar = anychart.scales.calendar();
calendar.timezoneOffset(-4*60); // Sets - 4 hours.

weekendRange

Getter for the regular weekend days.

Returns:

Array.<number> - The current weekend days.
Setter for the regular weekend days.

Params:

Name Type Description
var_value Array.<number> Holidays. 0 - monday, ... , 6 - sunday. Day number does not depend on localization.

Returns:

anychart.scales.Calendar - Self instance for method chaining.
Sets weekends
var calendar = anychart.scales.calendar();
calendar.weekendRange([0,6]);