Dependencies
Feature
This feature draws dependencies between tasks. Uses a dependency store to determine which dependencies to draw.
const project = new ProjectModel({ startDate : new Date(2020, 0, 1), events : [ { id : 1, name : 'Write docs', expanded : true, children : [ { id : 2, name : 'Proof-read docs', startDate : '2020-01-02', endDate : '2020-01-05' }, { id : 3, name : 'Release docs', startDate : '2020-01-09', endDate : '2020-01-10' } ] } ], dependencies : [ { id : 1, fromEvent : 2, toEvent : 3 } ] }); const gantt = new Gantt({ project, appendTo : targetElement, startDate : new Date(2019, 11, 31), endDate : new Date(2020, 0, 11), // autoHeight : true, height : 300, columns : [ { type : 'name', field : 'name', text : 'Name' } ] }); To customize the dependency tooltip, you can provide the tooltip config and specify a getHtml function. For example:
const gantt = new Gantt({
features : {
dependencies : {
tooltip : {
getHtml({ activeTarget }) {
const dependencyModel = gantt.resolveDependencyRecord(activeTarget);
if (!dependencyModel) return null;
const { fromEvent, toEvent } = dependencyModel;
return `${fromEvent.name} (${fromEvent.id}) -> ${toEvent.name} (${toEvent.id})`;
}
}
}
}
}
Styling all dependency lines
You can easily customize the arrows drawn between events. To change all arrows, apply the following basic SVG CSS:
.b-sch-dependency {
stroke-width: 2;
stroke : red;
}
.b-sch-dependency-arrow {
fill: red;
}
CSSHelper.insertRule(`.b-gantt .b-sch-dependency { stroke-width: 2; stroke : red; }`, targetElement.getRootNode()); const gantt = new Gantt({ appendTo : targetElement, flex : '1 0 100%', project : { startDate : new Date(2026, 0, 1), tasks : [ { id : 1, name : 'Write docs', startDate : '2026-01-01', endDate : '2026-01-03' }, { id : 2, name : 'Proof-read docs', startDate : '2026-01-03', endDate : '2026-01-05' }, { id : 3, name : 'Release docs', startDate : '2026-01-05', endDate : '2026-01-10' } ], dependencies : [ { id : 1, fromTask : 1, toTask : 2 }, { id : 2, fromTask : 2, toTask : 3 } ] }, startDate : new Date(2025, 11, 31), endDate : new Date(2026, 0, 11), height : 300 }); Styling individual dependency lines
To style an individual dependency line, you can provide a cls in your data:
{
"id" : 9,
"from" : 7,
"to" : 8,
"cls" : "special-dependency"
}
// Make line dashed
.b-sch-dependency {
stroke-dasharray: 5, 5;
}
CSSHelper.insertRule(`.b-gantt .b-sch-dependency-special-style { stroke-dasharray: 5, 5; stroke : blue; }`, targetElement.getRootNode()); const gantt = new Gantt({ appendTo : targetElement, flex : '1 0 100%', project : { startDate : new Date(2026, 0, 1), tasks : [ { id : 1, name : 'Write docs', startDate : '2026-01-01', endDate : '2026-01-03' }, { id : 2, name : 'Proof-read docs', startDate : '2026-01-02', endDate : '2026-01-05' }, { id : 3, name : 'Release docs', startDate : '2026-01-09', endDate : '2026-01-10' } ], dependencies : [ { id : 1, fromTask : 1, toTask : 2, cls : 'b-sch-dependency-special-style' }, { id : 2, fromTask : 2, toTask : 3 } ] }, startDate : new Date(2025, 11, 31), endDate : new Date(2026, 0, 11), height : 300 }); By default predecessors and successors in columns and the task editor are displayed using task id and name. The id part is configurable, any task field may be used instead (for example wbsCode or sequence number) by Gantt#dependencyIdField property.
const gantt = new Gantt({
dependencyIdField: 'wbsCode',
project,
columns : [
{ type : 'name', width : 250 }
],
});
Also see DependencyColumn#dependencyIdField to configure columns only if required.
This feature is enabled by default
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The CSS class applied to dependency lines
-
The clickable/touchable width of the dependency line in pixels. Draws an invisible but wider line along the same path as each dependency, making lines much easier to click and tap on touch devices. The tradeoff is that twice as many SVG lines will be drawn, which can affect performance with many visible dependencies. Set to
nullto disable the wider hit area and only use the visible line width.Has a corresponding runtime clickWidth property.
-
Specify
falseto prevent dependencies from being redrawn during event interaction, such as dragging, resizing or rescheduling through other means, including when events animate into place. This makes interaction smoother, but dependency lines will not be updated until the interaction is finished.Has a corresponding runtime drawOnEventInteraction property.
-
Specify
falseto prevent dependencies from being drawn during scroll, for smoother scrolling in schedules with lots of dependencies. Dependencies will be drawn when scrolling stops instead.Has a corresponding runtime drawOnScroll property.
-
Specify
falseto not enable simple deletion of dependencies by clicking on them.Has a corresponding runtime enableDelete property.
-
Specify
trueto highlight incoming and outgoing dependencies when hovering an event.Has a corresponding runtime highlightDependenciesOnEventHover property.
-
The CSS class applied to a too narrow dependency line (to hide markers)
-
The CSS class to add to a dependency line when hovering over it
-
The CSS class representing a delete icon shown when clicking a dependency line
-
Set to
falseto not allow creating dependencies -
Set it to
trueto allow dependency creation only for parent events (only applies to Scheduler Pro using theNestedEventsfeature). Normally the nested event container inside parent events cannot be scrolled when using dependencies, but by enabling this setting and limiting to where dependencies can be drawn scrolling will be enabled. -
falseto require a drop on a target event bar side circle to define the dependency type. If dropped on the event bar, thedefaultValueof the DependencyModeltypefield will be used to determine the target task side.Has a corresponding runtime allowDropOnEventBar property.
-
A tooltip config object that will be applied to the dependency creation Tooltip
-
falseto not show a tooltip while creating a dependency -
CSS class used for terminals
-
Where (on event bar edges) to display terminals. The sides are
'start','top','end'and'bottom' -
Set to
trueto show a tooltip when hovering a dependency lineHas a corresponding runtime showTooltip property.
-
A tooltip config object that will be applied to the dependency hover tooltip. Can be used to for example customize delay
-
Set to
trueto show the lag in 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.
-
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 Dependencies class, or subclass thereof.
-
Identifies an object as an instance of DependencyCreation class, or subclass thereof.
-
Identifies an object as an instance of DependencyTooltip 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.
-
A class property getter for the default values of internal properties for this class.
-
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 Dependencies class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
The clickable/touchable width of the dependency line in pixels. Draws an invisible but wider line along the same path as each dependency, making lines much easier to click and tap on touch devices. The tradeoff is that twice as many SVG lines will be drawn, which can affect performance with many visible dependencies. Set to
nullto disable the wider hit area and only use the visible line width.Has a corresponding clickWidth config.
-
Specify
falseto prevent dependencies from being redrawn during event interaction, such as dragging, resizing or rescheduling through other means, including when events animate into place. This makes interaction smoother, but dependency lines will not be updated until the interaction is finished.Has a corresponding drawOnEventInteraction config.
-
Specify
falseto prevent dependencies from being drawn during scroll, for smoother scrolling in schedules with lots of dependencies. Dependencies will be drawn when scrolling stops instead.Has a corresponding drawOnScroll config.
-
Specify
falseto not enable simple deletion of dependencies by clicking on them.Has a corresponding enableDelete config.
-
Specify
trueto highlight incoming and outgoing dependencies when hovering an event.Has a corresponding highlightDependenciesOnEventHover config.
-
falseto require a drop on a target event bar side circle to define the dependency type. If dropped on the event bar, thedefaultValueof the DependencyModeltypefield will be used to determine the target task side.Has a corresponding allowDropOnEventBar config.
-
A template function that will be called to generate the HTML contents of the dependency creation tooltip. You can return either an HTML string or a DomConfig object.
Has a corresponding creationTooltipTemplate config.
-
Set to
trueto show a tooltip when hovering a dependency lineHas a corresponding showTooltip config.
-
A template function allowing you to configure the contents of the tooltip shown when hovering a dependency line. You can return either an HTML string or a DomConfig object.
Has a corresponding tooltipTemplate config.
-
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
-
Create a new dependency from source terminal to target terminal
-
Deselects the dependency record
-
Redraws dependencies on the next animation frame
-
Aborts dependency creation, removes proxy and cleans up listeners
-
Creates a connector line that visualizes dependency source & target
-
Update connector line showing dependency between source and target when mouse moves. Also check if mouse is over a valid target terminal
-
Create a new dependency if mouse release over valid terminal. Hides connector
-
Remove hover styling when mouse leaves terminal. Also hides terminals when mouse leaves one it and not creating a dependency.
-
Start creating a dependency when mouse is pressed over terminal
-
Show terminals when mouse enters event/task element
-
Hide terminals when mouse leaves event/task element
-
Update dependency creation tooltip
-
Remove connector
-
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 code-
Fired when dependencies are rendered
Note that this event is triggered on the owning widget:
Event handlers
Event handlers are callbacks called as a result of certain actions in this class-
Called when dependencies are rendered
Note that this handler is called on the owning widget: