documentationfor yFiles for HTML 2.6

Reacting to Graph Changes

IGraph provides a comprehensive set of events for both structural changes of the graph like node creation or deletion as well as for visual changes like change of style, position, or size.

IGraph dispatches events upon each change, not only user driven but also by the program. This includes events dispatched during loading where a large number of elements are being created, events upon undo and redo actions, as well as events during an automatic layout. Briefly said, listening for events dispatched by IGraph may result in a huge number of events a developer is potentially not interested in. For almost all use cases, a developer wants to listen for user driven changes only. These kinds of changes are reported by the input mode used for editing graphs interactively.

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.

Reacting to Element Creation

These events are dispatched after the element has been created, i.e. at the time the event is dispatched the element is a valid element of the graph.

NodeCreated
Dispatched after a node has been created. The newly created node can be retrieved from the argument’s item property.
EdgeCreated
Dispatched after an edge has been created. The newly created edge can be retrieved from the argument’s item property.
BendAdded
Dispatched after a bend has been created. The newly created bend can be retrieved from the argument’s item property.
LabelAdded
Dispatched after a label has been created. The newly created label can be retrieved from the argument’s item property.
PortAdded
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, i.e. at the time the event is dispatched the element is no longer part of the graph. It also has no reference anymore to its former owner, source, or target port if applicable. The event arguments, however, provide this information.

NodeRemoved
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.
EdgeRemoved
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.
BendRemoved
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.
LabelRemoved
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.
PortRemoved
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.

Reacting to Other Structural Changes

EdgePortsChanged
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

NodeTagChanged
Dispatched after a node’s tag has been changed.
EdgeTagChanged
Dispatched after an edge’s tag has been changed.
BendTagChanged
Dispatched after a bend’s tag has been changed.
LabelTagChanged
Dispatched after a label’s tag has been changed.
PortTagChanged
Dispatched after a port’s tag has been changed.
GraphTagChanged
Dispatched after the graph’s tag has been changed.

Reacting to Layout and Geometry Changes

NodeLayoutChanged
Dispatched after a node’s layout has been changed.
BendLocationChanged
Dispatched after a bend’s location has been changed.
LabelLayoutParameterChanged
Dispatched after a label’s layout model parameter has been changed.
PortLocationParameterChanged
Dispatched after a port’s location model parameter has been changed.

Reacting to Other Property Changes

NodeStyleChanged
Dispatched after a node’s style has been changed.
EdgeStyleChanged
Dispatched after an edge’s style has been changed.
LabelStyleChanged
Dispatched after a label’s style has been changed.
LabelTextChanged
Dispatched after a label’s text has been changed.
LabelPreferredSizeChanged
Dispatched after the preferred size of a label has been changed.
PortStyleChanged
Dispatched after a port’s style has been changed.