TimeRanges
Feature
Feature that renders global ranges of time in the timeline. Use this feature to visualize a range like a 1 hr lunch or some important point in time (a line, i.e. a range with 0 duration). This feature can also show a current time indicator if you set showCurrentTimeLine to true. To style the rendered elements, use the cls field of the TimeSpan class.
targetElement.innerHTML = '<p>This demo shows how to add a TimeRange and how to display a current time line:</p>'; const first = DateHelper.startOf(new Date(), 'week'), scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, features : { timeRanges : { showCurrentTimeLine : true, showHeaderElements : true, enableResizing : true } }, startDate : first, endDate : DateHelper.add(first, 7, 'days'), columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Bernard' }, { id : 2, name : 'Bianca' } ], events : [ { id : 1, resourceId : 1, name : 'Interview', startDate : first, duration : 2, durationUnit : 'day' }, { id : 2, resourceId : 1, name : 'Press meeting', startDate : DateHelper.add(first, 4, 'days', true), duration : 2, durationUnit : 'day' }, { id : 3, resourceId : 2, name : 'Audition', startDate : DateHelper.add(first, 1, 'days'), duration : 2, durationUnit : 'day' }, { id : 4, resourceId : 2, name : 'Script deadline', startDate : DateHelper.add(first, 5, 'days'), duration : 2, durationUnit : 'day' } ], timeRanges : [ { id : 1, name : 'Cool range', startDate : DateHelper.add(first, 2, 'days'), duration : 1, durationUnit : 'day' } ] }); Each time range is represented by an instances of TimeSpan, held in a simple Store. The feature uses timeRangeStore defined on the project by default. The store's persisting/loading is handled by Crud Manager (if it's used by the component).
Note that the feature uses virtualized rendering, only the currently visible ranges are available in the DOM.
This feature is disabled by default. For info on enabling it, see GridFeatures.
Showing an icon in the time range header
You can use Font Awesome icons easily (or set any other icon using CSS) by using the iconCls field. The JSON data below will show a flag icon:
{
"id" : 5,
"iconCls" : "fa fa-flag",
"name" : "v5.0",
"startDate" : "2019-02-07 15:45"
},
Recurring time ranges
The feature supports recurring ranges in case the provided store and models have RecurringTimeSpansMixin and RecurringTimeSpan mixins applied:
// We want to use recurring time ranges, so we make a special model extending standard TimeSpan model with
// RecurringTimeSpan which adds recurrence support
class MyTimeRange extends RecurringTimeSpan(TimeSpan) {}
// Define a new store extending standard Store with RecurringTimeSpansMixin mixin to add recurrence support to the
// store. This store will contain time ranges.
class MyTimeRangeStore extends RecurringTimeSpansMixin(Store) {
static configurable = {
// use our new MyResourceTimeRange model
modelClass : MyTimeRange
}
};
// Instantiate store for timeRanges using our new classes
const timeRangeStore = new MyTimeRangeStore({
data : [{
id : 1,
resourceId : 'r1',
startDate : '2019-01-01T11:00',
endDate : '2019-01-01T13:00',
name : 'Lunch',
// this time range should repeat every day
recurrenceRule : 'FREQ=DAILY'
}]
});
const scheduler = new Scheduler({
...
features : {
timeRanges : true
},
crudManager : {
// store for "timeRanges" feature
timeRangeStore
}
});
Useful configs and functions
| Member | Description |
|---|---|
| showCurrentTimeLine | Show a line indicating current time |
| currentDateFormat | Date format for the current time header |
| currentTimeLineUpdateInterval | Interval for updating the current time line |
| dragTipTemplate | Template for the drag tooltip |
| currentTimelineUpdate | Fires when the current time line updates |
See also
- AbstractTimeRanges - Base time ranges feature
- TimeSpan - Time span data model
- ResourceTimeRanges - Per-resource time ranges
- NonWorkingTime - Non-working time highlighting
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The date format to show in the header for the current time line (when showCurrentTimeLine is configured). See DateHelper for the possible formats to use.
-
Set to
trueto enable dragging and resizing of range elements in the header. Note that enabling dragging/resizing also enables showHeaderElements automatically. -
A Tooltip config object which is applied to the tooltip shown when hovering a TimeRange header element
Has a corresponding runtime hoverTooltip property.
-
Set to
falseto not render range elements into the time axis header. Note that header elements are required for interaction such as dragging/resizing, so enabling enableResizing will automatically enable this setting.Has a corresponding runtime showHeaderElements property.
-
A Boolean specifying whether to show tooltip while resizing range elements, or a Tooltip config object which is applied to the tooltip
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
The interval (as amount of ms) defining how frequently the current timeline will be updated
-
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 Delayable class, or subclass thereof.
-
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 TimeRanges class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Set to
falseto not render range elements into the time axis header. Note that header elements are required for interaction such as dragging/resizing, so enabling enableResizing will automatically enable this setting.Has a corresponding showHeaderElements config.
-
Returns the TimeRanges which occur within the client Scheduler's time axis.
-
The Tooltip instance shown when hovering a TimeRange header element
Has a corresponding hoverTooltip 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 AbstractTimeRanges class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of TimeRanges 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
-
Returns the Store used by this feature. This is always the owning Scheduler/Gantt's Project TimeRangeStore.
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
-
Generates the html to display in the tooltip during drag drop. If you want to customize the contents of the tooltip, supply a dragTipTemplate instead of overriding this function.
-
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-current-time-color | Current time background & line color |
| --b-time-range-background | Time range background color |
| --b-time-range-color | Time range color |
| --b-time-range-header-background | Time range header background |
| --b-time-range-header-font-size | Time range header font size |
| --b-time-range-header-font-weight | Time range header font weight |
| --b-time-range-header-gap | Gap inside time range headers |
| --b-time-range-label-font-size | Time range label font size |
| --b-time-range-label-offset | Time range label offset from the line |
| --b-time-range-line-color | Time range line color |
| --b-time-range-line-header-background | Time range line header background color |
| --b-time-range-line-header-border-radius | Time range line header border radius |
| --b-time-range-line-header-padding-inline | Time range line header padding inline |
| --b-time-range-line-label-background | Time range line label background color |
| --b-time-range-line-label-border-radius | Time range line label border radius |
| --b-time-range-line-label-color | Time range line label color |
| --b-time-range-line-label-font-size | Time range line label font size |
| --b-time-range-line-label-offset | Time range line label offset |
| --b-time-range-line-label-padding | Time range line label padding |
| --b-time-range-line-opacity | Time range line opacity |
| --b-time-range-line-primary | Time range lines primary color |
| --b-time-range-line-style | Time range line style |
| --b-time-range-line-width | Time range line width |
| --b-time-range-line-zindex | Time line z-index |
| --b-time-range-opacity | Time range opacity |
| --b-time-range-range-zindex | Time range z-index |