sets the working time for the Gantt chart
config | object | the configuration object of a time span |
gantt.config.work_time = true;
//changes the working time of working days from ["8:00-17:00"] to ["9:00-18:00"]
gantt.setWorkTime({ hours:["9:00-18:00"] });
//makes all Fridays day-offs
gantt.setWorkTime({ day:5, hours:false });
//changes the working time for Fridays and Saturdays
// from ["8:00-17:00"] to ["8:00-12:00"]
gantt.setWorkTime({day : 5, hours : ["8:00-12:00"]});
gantt.setWorkTime({day : 6, hours : ["8:00-12:00"]});
//makes March 31 a working day
gantt.setWorkTime({date : new Date(2013, 2, 31)});
//makes January 1 a day-off
gantt.setWorkTime({date:new Date(2013,0,1), hours:false})
//sets working time as 2 periods: 8:30-12:00, 13:00-17:00 (to keep time for lunch)
gantt.setWorkTime({hours : ["8:30-12:00", "13:00-17:00"]})
The method makes sense only if work_time is set to 'true'. Otherwise, the method will be ignored.
The default working time is the following:
The method is used to alter the default settings.
The configuration object can contain the following properties:
Property | Description |
---|---|
day | a number of a week day [0 (Sunday) - 6 (Saturday)]. Note, you can set only 1 day at once |
|
|
date | a specific date to set as a working day or day off |
|
|
hours | an array of working hours as 'from'-'to' pairs. 'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"]) |
|
|
customWeeks | an object with different working-time rules for different periods of time. The object can contain a set of key:value pairs where key is the name of a time span and value is an object that includes the following attributes:
|
|
Working time settings for the hours attribute of the setWorkTime method' config object should be specified from
the lesser interval to the greater one, that is in the ascending order. In case time settings are provided in the descending order, part of them
will be ignored. In the example below the time intervals after 18:00
will be ignored:
// the settings below are incorrect
gantt.setWorkTime({day : 5, hours : ["16:00-18:00", "14:00-15:00", "08:00-10:00"]});
gantt.setWorkTime({day : 5, hours : ["16:00-18:00", "00:00-04:00", "05:00-06:00"]});
If you need to specify working time settings for the night shift, you should set them in the following way:
For example:
gantt.setWorkTime({day : 5, hours : ["16:00-18:00"]});
gantt.setWorkTime({day : 6, hours : ["00:00-04:00", "05:00-06:00"]});
Note, each next call of the method for the same date will re-write the previous working-time rule:
gantt.setWorkTime({hours:["8:00-12:00"]});
gantt.setWorkTime({hours:["13:00-17:00"]});
//the result of the above commands will be the working time 13:00-17:00
//and not a mixin of both commands