documentationfor yFiles for HTML 3.0.0.3

Reacting to Graph Changes

IGraph provides a comprehensive set of events for both structural changes of the graph (such as node creation or deletion) and for visual changes (such as changes to style, position, or size).

Important
IGraph dispatches events upon every change, whether it’s user-driven or programmatically initiated. This includes events dispatched during loading (when many elements are being created), during undo and redo actions, and during automatic layout. Listening for events dispatched by IGraph may result in a large number of events that a developer might not be interested in.
Important
It is strongly discouraged to make any changes (e.g. move or remove elements) to the graph structure in handlers to these events. It is possible that the graph is not yet in a defined state at the time these events are raised. This might result in exceptions which can be hard to predict. This holds especially if folding is enabled.
Important
It is strongly discouraged to make any changes to the graph structure (e.g., moving or removing elements) within the event handlers for these events. The graph might not be in a defined state when these events are raised, which can result in unpredictable exceptions. This is especially true if folding is enabled.

Reacting to Element Creation

These events are dispatched after the element has been created. When the event is dispatched, the element is a valid element of the graph.

node-created

Dispatched after a node has been created. The newly created node can be retrieved from the argument’s item property.

edge-created

Dispatched after an edge has been created. The newly created edge can be retrieved from the argument’s item property.

bend-added

Dispatched after a bend has been created. The newly created bend can be retrieved from the argument’s item property.

label-added

Dispatched after a label has been created. The newly created label can be retrieved from the argument’s item property.

port-added

Dispatched after a port has been created. The newly created port can be retrieved from the argument’s item property.

Reacting to Element Removal

These events are dispatched after the element has been removed. At the time the event is dispatched, the element is no longer part of the graph and has no reference to its former owner, source, or target port (if applicable). The event arguments, however, provide this information.

node-removed

Dispatched after a node has been removed. The removed node can be retrieved from the argument’s item property. Its former grouping states can be retrieved from the parent and isGroupNode properties.

edge-removed

Dispatched after an edge has been removed. The removed edge can be retrieved from the argument’s item property. Its former source and target ports and port owners can be retrieved from the sourcePort, targetPort, sourcePortOwner, and targetPortOwner properties, respectively.

bend-removed

Dispatched after a bend has been removed. The removed bend can be retrieved from the argument’s item property. Its former owner and index in the owner’s bends collection can be retrieved from the owner and index properties, respectively.

label-removed

Dispatched after a label has been removed. The removed label can be retrieved from the argument’s item property. Its former owner can be retrieved from the owner property.

port-removed

Dispatched after a port has been removed. The removed port can be retrieved from the argument’s item property. Its former owner can be retrieved from the owner property.

is-group-node-changed

Dispatched after a node’s group node state has been changed. The changed node can be retrieved from the argument’s item property. Its former grouping state can be retrieved from the isGroupNode property.

parent-changed

Dispatched after a node’s parent has been changed. The reparented node can be retrieved from the argument’s item property. Its former parent can be retrieved from the parent property.

Reacting to Other Structural Changes

edge-ports-changed

Dispatched after the source and/or target port of an edge has been changed. The changed edge can be retrieved from the argument’s item property. Its former source and target ports and port owners can be retrieved from the sourcePort, targetPort, sourcePortOwner, and targetPortOwner properties, respectively.

Reacting to Tag Changes

node-tag-changed

Dispatched after a node’s tag has been changed.

edge-tag-changed

Dispatched after an edge’s tag has been changed.

bend-tag-changed

Dispatched after a bend’s tag has been changed.

label-tag-changed

Dispatched after a label’s tag has been changed.

port-tag-changed

Dispatched after a port’s tag has been changed.

graph-tag-changed

Dispatched after the graph’s tag has been changed.

Reacting to Layout and Geometry Changes

node-layout-changed

Dispatched after a node’s layout has been changed.

bend-location-changed

Dispatched after a bend’s location has been changed.

label-layout-parameter-changed

Dispatched after a label’s layout model parameter has changed.

port-location-parameter-changed

Dispatched after a port’s location model parameter has changed.

Reacting to Other Property Changes

node-style-changed

Dispatched after a node’s style is changed.

edge-style-changed

Dispatched after an edge’s style is changed.

label-style-changed

Dispatched after a label’s style is changed.

label-text-changed

Dispatched after a label’s text is changed.

label-preferred-size-changed

Dispatched after the preferred size of a label is changed.

port-style-changed

Dispatched after a port’s style is changed.