v7.3.0
SupportExamplesFree Trial

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

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • baseCls : Stringb-sch-dependency
    private
    Dependencies

    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 null to disable the wider hit area and only use the visible line width.

    Has a corresponding runtime clickWidth property.

  • Specify false to 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 false to 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 false to not enable simple deletion of dependencies by clicking on them.

    Has a corresponding runtime enableDelete property.

  • Specify true to highlight incoming and outgoing dependencies when hovering an event.

    Has a corresponding runtime highlightDependenciesOnEventHover property.

  • noMarkerCls : Stringb-sch-dependency-markerless
    private
    Dependencies

    The CSS class applied to a too narrow dependency line (to hide markers)

  • overCls : Stringb-sch-dependency-over
    private
    Dependencies

    The CSS class to add to a dependency line when hovering over it

  • removeIconCls : Stringb-icon b-icon-remove-circle
    Dependencies

    The CSS class representing a delete icon shown when clicking a dependency line

  • Set to false to not allow creating dependencies

  • Set it to true to allow dependency creation only for parent events (only applies to Scheduler Pro using the NestedEvents feature). 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.

  • false to require a drop on a target event bar side circle to define the dependency type. If dropped on the event bar, the defaultValue of the DependencyModel type field 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

  • false to 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 true to show a tooltip when hovering a dependency line

    Has 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 true to 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 false to disable localization of this object.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isDelayable : Booleantrue
    READONLY
    static
    ADVANCED
    Delayable
    Identifies an object as an instance of Delayable class, or subclass thereof.
  • isDependencies : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of Dependencies class, or subclass thereof.
  • isDependencyCreation : Booleantrue
    READONLY
    static
    ADVANCED
    DependencyCreation
    Identifies an object as an instance of DependencyCreation class, or subclass thereof.
  • isDependencyTooltip : Booleantrue
    READONLY
    static
    ADVANCED
    DependencyTooltip
    Identifies an object as an instance of DependencyTooltip class, or subclass thereof.
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • properties : Object
    internal
    static
    InstancePlugin

    A class property getter for the default values of internal properties for this class.

  • emptyArray : Array
    internal
    READONLY
    InstancePlugin

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    InstancePlugin

    An empty object that can be used as a default value.

  • isDependencies : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of Dependencies class, or subclass thereof.
  • isInstancePlugin : Booleantrue
    READONLY
    ADVANCED
    InstancePlugin
    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 null to disable the wider hit area and only use the visible line width.

    Has a corresponding clickWidth config.

  • Specify false to 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 false to 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 false to not enable simple deletion of dependencies by clicking on them.

    Has a corresponding enableDelete config.

  • Specify true to highlight incoming and outgoing dependencies when hovering an event.

    Has a corresponding highlightDependenciesOnEventHover config.

  • false to require a drop on a target event bar side circle to define the dependency type. If dropped on the event bar, the defaultValue of the DependencyModel type field 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 true to show a tooltip when hovering a dependency line

    Has 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.

  • config : Object
    READONLY
    ADVANCED
    InstancePlugin

    Returns a copy of the full configuration which was used to configure this object.

  • This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    InstancePlugin

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • client : Widget
    READONLY
    ADVANCED
    InstancePlugin

    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
  • onClassMixedIn( )
    internal
    static
    InstancePlugin

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    InstancePlugin

    Registers this class type with its Factory

  • createDependency( )
    internal
    ASYNC

    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

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    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
id: dependencies

Source path

Gantt/feature/Dependencies.js

Demo

examples/basic

Contents