Dependencies
Feature
Feature that draws dependencies between events. Uses a DependencyStore to determine which dependencies to draw, if none is defined one will be created automatically. Dependencies can also be specified as scheduler.dependencies, see example below:
Dependencies also work in vertical mode:
To customize the dependency tooltip, you can use the tooltipTemplate. For example:
const scheduler = new Scheduler({
features : {
dependencies : {
tooltipTemplate(dependencyModel) {
const { fromEvent, toEvent } = dependencyModel;
return `${fromEvent.name} (${fromEvent.id}) -> ${toEvent.name} (${toEvent.id})`;
}
}
}
}
Styling 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;
}
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.special-dependency {
stroke-dasharray: 5, 5;
}
To customize the marker used for the lines (the arrow header), you can supply a SVG path definition to the markerDef config:
You can also specify a radius to get lines with rounded "corners", for a less boxy look:
For advanced use cases, you can also manipulate the DomConfig used to create a dependency line in a renderer function.
Adjusting terminals
When hovering an event bar, terminals (connection points) for creating new dependencies are shown. By default, they have a diameter of 12px and are positioned at the edge of the event bar. You can customize this by setting terminalSize and terminalOffset. The example below uses larger terminals offset to outside the event bar:
This feature is disabled by default. For info on enabling it, see GridFeatures.
Useful configs and functions
| Member | Description |
|---|---|
| dependencyClick | Fires when a dependency line is clicked |
| dependencyDblClick | Fires on dependency double-click |
| dependencyContextMenu | Fires on dependency right-click |
| dependenciesDrawn | Fires after all dependency lines are drawn |
| dependencyMouseOver | Fires when pointer enters a dependency |
See also
- DependencyModel - Dependency data model
- DependencyStore - Dependency store
- DependencyEdit - Dependency editor
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
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Dependencies 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.
-
Identifies an object as an instance of Dependencies class, or subclass thereof.
Functions
Functions are methods available for calling on the class-
Deselects the dependency record
-
refresh( )
Redraws dependencies on the next animation frame
Events
Events are triggered for certain actions in this class and can be listened for to react to those actions in your code-
dependenciesDrawnON-OWNER
Fired when dependencies are rendered
Note that this event is triggered on the owning widget: