TaskNonWorkingTime
Feature
Feature highlighting the non-working time intervals for tasks, based on their calendar. If a task has no calendar defined, the project's calendar will be used. The non-working time interval can also be recurring. You can find a live example showing how to achieve this in the Task Calendars Demo.
const gantt = new Gantt({ appendTo : targetElement, // makes the Gantt chart as tall as it needs to be to fit all rows autoHeight : true, columns : [ { type : 'name', width : 150 }, { type : 'calendar' } ], features : { taskNonWorkingTime : true }, project : { startDate : new Date(2022, 7, 4), tasks : [ { id : 1, name : 'Task 1', calendar : 'mon-thu', duration : 5 }, { id : 2, name : 'Task 2', calendar : 'break', duration : 5 } ], calendars : [ { id : 'general', name : 'General', intervals : [ { recurrentStartDate : 'on Sat', recurrentEndDate : 'on Mon', isWorking : false } ] }, { id : 'mon-thu', name : 'Mon-Thu', intervals : [ { recurrentStartDate : 'on Fri', recurrentEndDate : 'on Mon', isWorking : false } ] }, { id : 'break', name : 'Breaks', intervals : [ { startDate : '2022-08-07', endDate : '2022-08-11', isWorking : false }, { startDate : '2022-08-18', endDate : '2022-08-20', isWorking : false } ] } ] } }); The demo above shows the default row mode, but the feature also supports a barmode that shades parts of the task bars:
const gantt = new Gantt({ appendTo : targetElement, // makes the Gantt chart as tall as it needs to be to fit all rows autoHeight : true, columns : [ { type : 'name', width : 150 }, { type : 'calendar' } ], features : { taskNonWorkingTime : { mode : 'bar' } }, project : { startDate : new Date(2022, 7, 4), tasks : [ { id : 1, name : 'Task 1', calendar : 'mon-thu', duration : 5 }, { id : 2, name : 'Task 2', calendar : 'break', duration : 5 } ], calendars : [ { id : 'general', name : 'General', intervals : [ { recurrentStartDate : 'on Sat', recurrentEndDate : 'on Mon', isWorking : false } ] }, { id : 'mon-thu', name : 'Mon-Thu', intervals : [ { recurrentStartDate : 'on Fri', recurrentEndDate : 'on Mon', isWorking : false } ] }, { id : 'break', name : 'Breaks', intervals : [ { startDate : '2022-08-07', endDate : '2022-08-11', isWorking : false }, { startDate : '2022-08-18', endDate : '2022-08-20', isWorking : false } ] } ] } }); If you want a tooltip to be displayed when hovering over the non-working time interval, you can configure a tooltipTemplate.
Data structure
Below you see an example of data defining calendars and assigning the tasks a calendar:
const gantt = new Gantt({
features : {
taskNonWorkingTime : true
},
// A Project holding the data and the calculation engine for the Gantt. It also acts as a CrudManager, allowing
project : {
tasks : [
{ id : 1, name : 'Task 1' },
{ id : 2, name : 'Task 2', calendar : 'break' }
],
calendars : [
{
id : 'general',
name : 'General',
intervals : [
{
recurrentStartDate : 'on Sat',
recurrentEndDate : 'on Mon',
isWorking : false
}
]
},
{
id : 'break',
name : 'Breaks',
intervals : [
{
startDate : '2022-08-07',
endDate : '2022-08-11',
isWorking : false
},
{
startDate : '2022-08-18',
endDate : '2022-08-20',
isWorking : false
}
]
}
]
}
}):
Styling non-working time interval elements
To style the elements representing the non-working time elements you can set the cls field in your data. This will add a CSS class to all non-working time elements for the calendar. You can also add an iconCls value specifying an icon to display inside the interval.
{
"success" : true,
"calendars" : {
"rows" : [
{
"id" : "day",
"name" : "Day shift",
"unspecifiedTimeIsWorking" : false,
"cls" : "dayshift",
"intervals" : [
{
"recurrentStartDate" : "at 8:00",
"recurrentEndDate" : "at 17:00",
"isWorking" : true
}
]
}
]
}
}
You can also add a cls value and an iconCls to individual intervals:
{
"success" : true,
"calendars" : {
"rows" : [
{
"id" : "day",
"name" : "Day shift",
"unspecifiedTimeIsWorking" : true,
"intervals" : [
{
"startDate" : "2022-03-23T02:00",
"endDate" : "2022-03-23T04:00",
"isWorking" : false,
"cls" : "factoryShutdown",
"iconCls" : "warningIcon"
}
]
}
]
}
}
This feature is disabled by default. For info on enabling it, see GridFeatures.
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Rendering mode, one of:
- 'row' - renders non-working time intervals to the task row
- 'bar' - renders non-working time intervals inside the task bar
- 'both - combines 'row' and 'bar' rendering modes
Has a corresponding runtime mode property.
-
Config that allows rendering to take into account the Gantt fillTicks config:
true- renders non-working time intervals taking into account the Gantt fillTicks configfalse- (default) renders non-working time intervals without taking into account the Gantt fillTicks config
Has a corresponding runtime respectFillTicks property.
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of TaskNonWorkingTime class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Rendering mode, one of:
- 'row' - renders non-working time intervals to the task row
- 'bar' - renders non-working time intervals inside the task bar
- 'both - combines 'row' and 'bar' rendering modes
Has a corresponding mode config.
-
Config that allows rendering to take into account the Gantt fillTicks config:
true- renders non-working time intervals taking into account the Gantt fillTicks configfalse- (default) renders non-working time intervals without taking into account the Gantt fillTicks config
Has a corresponding respectFillTicks config.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of TaskNonWorkingTime class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.
Events
Events are triggered for certain actions in this class and can be listened for to react to those actions in your codeEvent handlers
Event handlers are callbacks called as a result of certain actions in this classCSS variables
CSS variables that can be set to adjust appearance| Name | Description |
|---|---|
| --b-task-non-working-time-background | Task non-working time background |
| --b-task-non-working-time-color | Task non-working time text color |
| --b-task-non-working-time-font-size | Task non-working time font size |
| --b-task-non-working-time-z-index | Task non-working time z index |