createTimelineView
info
This functionality is available in the PRO edition only.
Description
Creates the Timeline view in the scheduler.
createTimelineView: (config: any) => void
Parameters
config- (required) object - the configuration object of the Timeline view
Example
// the time scale from 8 AM to 8 PM with a 30-minute step
scheduler.createTimelineView({
name: "timeline",
x_unit: "minute",
x_date: "%H:%i",
x_step: 30,
x_size: 24,
x_start: 16,
x_length: 48,
fit_events_offset: 15,
y_unit: [
{ key: 1, label: "Section A" },
{ key: 2, label: "Section B" },
{ key: 3, label: "Section C" },
{ key: 4, label: "Section D" }
],
y_property: "section_id",
render: "bar"
});
Applicable views: Timeline view
Related samples
Details
note
The method requires the timeline plugin to be activated.
The configuration object of the Timeline view can have the following properties:
name- (string) the view's id. If you specify the name of some already existing Timeline view, it will be overwrittenrender- ('cell', 'bar', 'tree', 'days') the view's mode. By default, 'cell'y_property- (string) the name of a data property that will be used to assign events to certain sectionsy_unit- (array of objects) defines sections of the view. Each object in the array specifies a single section and takes these properties:children- (array) an array of nested items' objects (for 'Tree' mode only)key- (string) the section's id. This attribute is compared with the event's data property to assign the event to a sectionlabel- (string) the section's labelopen- (boolean) specifies whether the section will be opened initially (for 'Tree' mode only)
days- (number) a number of items (days) in the Y-Axis. Applicable to the 'Days' mode onlyx_unit- (minute, hour, day, week, month, year) the measuring unit of the X-Axis. By default, 'minute'x_date- (string) the date format of the X-Axis. If not specified, thehour_dateformat is usedx_step- (number) the X-Axis step inx_units. By default, 1x_start- (number) the X-Axis offset inx_units. By default, 0x_size- (number) the X-Axis length specified as the total number ofx_steps. By default, 24x_length- (number) the number ofx_steps that will be scrolled at a time, when the user clicks on the 'next' button in the scheduler's header. Optional. By default, 1. It's a bit knotty parameter, and to not make a mistake, remember the following:- You can use the parameter only if
x_unit='minute'orx_unit='hour'. In other cases, the parameter doesn't need specifying at all. - If
x_unit='minute'orx_unit='hour'and you don't specifyx_length, the X-Axis will display the time interval (not the whole day, as usual) specified by the remaining scale parameters (x_start,x_step,x_size). This allows you to divide a day into equal time intervals and scroll them with the 'next' button. - If
x_unit='minute'orx_unit='hour'and you decide to set the parameter, set it to all day (i.e.x_lengthshould be equal to the number ofx_stepsneeded to fill the whole day) to provide correct work of the 'next' button.
- You can use the parameter only if
first_hour- (number) sets the start hour of the cell's time interval. The attribute is applicable only ifx_unit="day"last_hour- (number) sets the end hour of the cell's time interval. The attribute is applicable only ifx_unit="day"show_unassigned- (boolean) if false, events which belong to none of the sections won't be displayed. If true - such events will be placed to the first section. By default - false. Optionalsection_autoheight- (boolean) enables automatic height adjustment for cells. By default, truedy- (number) the minimum height of cells (if thesection_autoheightproperty has value false, the height of cells will be equal tody, otherwise the height of cells will be increased to fill all free space). By default, 50dx- (number) the width of the column with the sections' names. By default, 200event_dy- (number/string) the height of events. Can have thefullvalue and occupy the entire cell. By default, equal toscheduler.xy.bar_height-5event_min_dy- (number) the minimum event height. By default, equal toscheduler.xy.bar_height-5resize_events- (boolean) specifies whether the height of individual events should be decreased, to make the total height equal to the height of one single event (but not less than the value of theevent_min_dyproperty). By default, truefit_events- (boolean) specifies whether the section's height should be increased, to fit all events in this section, or should be fixed (thedyparameter). Available from version 3.0. By default, truefit_events_offset- (number) adds extra space (in pixels) under the last event. It is applied whenfit_eventsis set to trueround_position- (boolean) 'stretches' the events all over the entire cell width, no matter how long the event lasts. By default, false. For 'Bar' and 'Tree' modes onlyfolder_events_available- (boolean) should be set as true, if you want to have the possibility to specify events not only for an individual holder, but also for the whole folder (any level). Applicable to the 'Tree' mode only. By default, falsefolder_dy- (number) the height of folders in pixels (folders are sections that have child sections). Applicable to the 'Tree' mode onlysecond_scale- (object) adds the second X-Axis on the top of the default one and serves to group time intervals on the original scale. Optional. Available from version 3.0. The scale object has the following properties:scrollable- (boolean) enables horizontal scroll in the Timeline view, false by default. If false or undefined, date columns will shrink to fit the time scale into the viewport width. If true, date columns will not shrink less than thecolumn_widthvalue, a horizontal scroll bar will appear when necessary.column_width- (number) defines the minimal width of timeline date columns, 100 by defaultscroll_position- (Date) renders timeline scrolled to a specific position, takes the same arguments astimeline.scrollTo(), i.e. the date you want timeline to be scrolled to after renderingautoscroll- (object) allows configuring sensibility and speed of autoscroll. The autoscroll object has the properties below:range_x- (number) horizontal autoscroll distance from the edge of the data arearange_y- (number) vertical autoscroll distance from the edge of the data areaspeed_x- (number) horizontal autoscroll speedspeed_y- (number) vertical autoscroll speed
cell_template- (boolean) enables rendering a template specified for a timelinesmart_rendering- (boolean) enables smart rendering functionality in a timeline (allows rendering only the rows, columns, and events visible on the screen, while other elements are being rendered during scrolling of the timeline). Note that in a scrollable timeline this setting is enabled by default.columns- (array) a list of columns for the left-hand panel. If not specified, thetimeline_scale_labeltemplate will be used for the content of the panel.
Dynamic change of properties
All defined timeline objects are stored in the scheduler.matrix object.
You can access the configuration of any timeline view by its name and change any property. Changes will be applied as soon as you update the scheduler with setCurrentView():
scheduler.getView('timeline').x_size = 12;
scheduler.setCurrentView(); // redraws scheduler
where "timeline" is the name of the timeline view as specified in the createTimelineView() method:
scheduler.createTimelineView({
name: "timeline",
...
});
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.