This class is used to provide additional data to the graph and its elements that can be utilized by layout algorithms during computation.
Remarks
Data is stored on the graph using unique lookup key instances, typically defined by layout algorithms. Client code or LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> can supply additional data associated with a particular key. Layout algorithms can then retrieve this data using the keys and utilize it for computation.
Data can be added to the entire graph or to its individual elements, such as LayoutNodes, LayoutEdges, LayoutNodeLabels, and LayoutEdgeLabels. Adding data per element is facilitated by using IMapper<K,V>, ItemMapping<TItem,TValue>, or data getter. An ItemCollection<TItem> enables the definition of collections of elements. Additionally, shared information can be stored as a constant value for all elements of a certain type.
Data associated with a specific key can also be temporarily hidden or replaced. Replacing data is achieved by pushing a new layer onto the context, registering the new data with the same key, and subsequently removing the layer once the data is no longer needed.
This class cannot be instantiated
Type Details
- yFiles module
- algorithms
See Also
Properties
Gets the copy information that offers mappings between items in this graph and an original graph for instances that were created as a copy of another graph by using createCopy.
Remarks
null
for graphs that were not created via method createCopy.Gets or sets the LayoutAbortController used during the layout.
Remarks
See Also
Methods
Registers a single value data for the graph with the specified ValueDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - ValueDataKey<TValue>
- The ValueDataKey<TValue> the data should be registered for.
- data - TValue
- The data to register.
See Also
addItemConstantData
<TValue>(dataKey: NodeDataKey<TValue>, constantValue: TValue) : IMapper<LayoutNode,TValue>Registers a constant value for all nodes at the graph with the specified data key.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the value to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<TValue>
- The NodeDataKey<TValue> the data should be registered for.
- constantValue - TValue
- The value returned as data for all nodes.
Returns
- ↪IMapper<LayoutNode,TValue>
- The created IMapper<Node,TValue> for the given constant.
addItemConstantData
<TValue>(dataKey: EdgeDataKey<TValue>, constantValue: TValue) : IMapper<LayoutEdge,TValue>Registers a constant value for all edges at the graph with the specified data key.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the value to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<TValue>
- The EdgeDataKey<TValue> the data should be registered for.
- constantValue - TValue
- The value returned as data for all edges.
Returns
- ↪IMapper<LayoutEdge,TValue>
- The created IMapper<Edge,TValue> for the given constant.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<TValue>
- The NodeDataKey<TValue> the data should be registered for.
- mapper - IMapper<LayoutNode,TValue>
- The IMapper<K,V> that stores the data for each node.
addItemData
<TValue>(dataKey: NodeDataKey<TValue>, getter: function(LayoutNode):TValue, setter?: function(LayoutNode, TValue):void) : IMapper<LayoutNode,TValue>Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<TValue>
- The NodeDataKey<TValue> the data should be registered for.
- getter - function(LayoutNode):TValue
- A callback to get the data for a node in the created mapper.
Signature Details
function(key: LayoutNode) : TValue
A delegate that mimics the get access.Parameters
- key - LayoutNode
- The key of the mapping.
Returns
- TValue
- The value or a suitable default that is associated with
key
.
- setter - function(LayoutNode, TValue):void
- A callback to set the data for a node in the created mapper.
Signature Details
function(key: LayoutNode, value: TValue)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - LayoutNode
- The key of the mapping.
- value - TValue
- The new value of the mapping.
Returns
- ↪IMapper<LayoutNode,TValue>
- The created IMapper<K,V> using the given getter and setter callbacks.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<TValue>
- The EdgeDataKey<TValue> the data should be registered for.
- mapper - IMapper<LayoutEdge,TValue>
- The IMapper<K,V> that stores the data for each edge.
addItemData
<TValue>(dataKey: EdgeDataKey<TValue>, getter: function(LayoutEdge):TValue, setter?: function(LayoutEdge, TValue):void) : IMapper<LayoutEdge,TValue>Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<TValue>
- The EdgeDataKey<TValue> the data should be registered for.
- getter - function(LayoutEdge):TValue
- A callback to get the data for an edge in the created mapper.
Signature Details
function(key: LayoutEdge) : TValue
A delegate that mimics the get access.Parameters
- key - LayoutEdge
- The key of the mapping.
Returns
- TValue
- The value or a suitable default that is associated with
key
.
- setter - function(LayoutEdge, TValue):void
- A callback to set the data for an edge in the created mapper.
Signature Details
function(key: LayoutEdge, value: TValue)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - LayoutEdge
- The key of the mapping.
- value - TValue
- The new value of the mapping.
Returns
- ↪IMapper<LayoutEdge,TValue>
- The created IMapper<K,V> using the given getter and setter callbacks.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> the data should be registered for.
- mapper - IMapper<LayoutNodeLabel,TValue>
- The IMapper<K,V> that stores the data for each node label.
addItemData
<TValue>(dataKey: NodeLabelDataKey<TValue>, getter: function(LayoutNodeLabel):TValue, setter?: function(LayoutNodeLabel, TValue):void) : IMapper<LayoutNodeLabel,TValue>Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> the data should be registered for.
- getter - function(LayoutNodeLabel):TValue
- A callback to get the data for a node label in the created mapper.
Signature Details
function(key: LayoutNodeLabel) : TValue
A delegate that mimics the get access.Parameters
- key - LayoutNodeLabel
- The key of the mapping.
Returns
- TValue
- The value or a suitable default that is associated with
key
.
- setter - function(LayoutNodeLabel, TValue):void
- A callback to set the data for a node label in the created mapper.
Signature Details
function(key: LayoutNodeLabel, value: TValue)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - LayoutNodeLabel
- The key of the mapping.
- value - TValue
- The new value of the mapping.
Returns
- ↪IMapper<LayoutNodeLabel,TValue>
- The created IMapper<K,V> using the given getter and setter callbacks.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> the data should be registered for.
- mapper - IMapper<LayoutEdgeLabel,TValue>
- The IMapper<K,V> that stores the data for each edge label.
addItemData
<TValue>(dataKey: EdgeLabelDataKey<TValue>, getter: function(LayoutEdgeLabel):TValue, setter?: function(LayoutEdgeLabel, TValue):void) : IMapper<LayoutEdgeLabel,TValue>Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- TValue
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> the data should be registered for.
- getter - function(LayoutEdgeLabel):TValue
- A callback to get the data for an edge label in the created mapper.
Signature Details
function(key: LayoutEdgeLabel) : TValue
A delegate that mimics the get access.Parameters
- key - LayoutEdgeLabel
- The key of the mapping.
Returns
- TValue
- The value or a suitable default that is associated with
key
.
- setter - function(LayoutEdgeLabel, TValue):void
- A callback to set the data for an edge label in the created mapper.
Signature Details
function(key: LayoutEdgeLabel, value: TValue)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - LayoutEdgeLabel
- The key of the mapping.
- value - TValue
- The new value of the mapping.
Returns
- ↪IMapper<LayoutEdgeLabel,TValue>
- The created IMapper<K,V> using the given getter and setter callbacks.
Gets the single value data registered for the graph with the specified ValueDataKey<TValue>.
Remarks
If no data is registered under the given dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.
Use this method when the type TValue
is a class or nullable value type (struct). If TValue
is a struct, use getNullableData instead. Otherwise, this method throws an exception if no value is registered.
Type Parameters
- TValue
- The type of the returned data.
Parameters
A map of options to pass to the method.
- dataKey - ValueDataKey<TValue>
- The ValueDataKey<TValue> for retrieving the data.
Returns
- ↪TValue?
- The single value data registered for the graph with the specified
dataKey
, ornull
if nothing is registered.
Throws
- Exception({ name: 'NullReferenceError' })
- Thrown if the data type is a value type (struct) and no value is registered with the
dataKey
. In such cases, use getNullableData instead.
Gets data for individual nodes registered for the graph with the specified NodeDataKey<TValue>.
Remarks
dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.Type Parameters
- TValue
- The type of the data values in the
.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<TValue>
- The NodeDataKey<TValue> for retrieving the IMapper<K,V>.
Returns
- ↪IMapper<LayoutNode,TValue>?
- The IMapper<K,V> registered for the graph with the specified
dataKey
.
Gets data for individual edges registered for the graph with the specified EdgeDataKey<TValue>.
Remarks
dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.Type Parameters
- TValue
- The type of the data values in the
.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<TValue>
- The EdgeDataKey<TValue> for retrieving the IMapper<K,V>.
Returns
- ↪IMapper<LayoutEdge,TValue>?
- The IMapper<K,V> registered for the graph with the specified
dataKey
.
Gets data for individual node labels registered for the graph with the specified NodeLabelDataKey<TValue>.
Remarks
dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.Type Parameters
- TValue
- The type of the data values in the
.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> for retrieving the IMapper<K,V>.
Returns
- ↪IMapper<LayoutNodeLabel,TValue>?
- The IMapper<K,V> registered for the graph with the specified
dataKey
.
Gets data for individual edge labels registered for the graph with the specified EdgeLabelDataKey<TValue>.
Remarks
dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.Type Parameters
- TValue
- The type of the data values in the
.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> for retrieving the IMapper<K,V>.
Returns
- ↪IMapper<LayoutEdgeLabel,TValue>?
- The IMapper<K,V> registered for the graph with the specified
dataKey
.
Gets the single value data registered for the graph with the specified ValueDataKey<TValue>, modifying the type to be nullable.
Remarks
If no data is registered under the given dataKey
, this method recursively searches the underlying layers for data associated with the dataKey
.
Use this method when the type TValue
is a value data type (struct). If nothing is registered, null
will be returned. For other data types, use the getData method instead.
Type Parameters
- TValue
- The type of the returned data.
Parameters
A map of options to pass to the method.
- dataKey - ValueDataKey<TValue>
- The ValueDataKey<TValue> for retrieving the data.
Returns
- ↪TValue?
- The single value data registered for the graph with the specified
dataKey
, ornull
if nothing is registered.
Hides the data registered for the graph with the specified ValueDataKey<TValue>.
Type Parameters
- TValue
- The type of the data to hide.
Parameters
A map of options to pass to the method.
- key - ValueDataKey<TValue>
- The ValueDataKey<TValue> for the data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
key
is null.
Hides the item data registered for the graph with the specified NodeDataKey<TValue>.
Type Parameters
- TValue
- The type of the data to hide.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<TValue>
- The NodeDataKey<TValue> for the item data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
dataKey
is null.
Hides the item data registered for the graph with the specified EdgeDataKey<TValue>.
Type Parameters
- TValue
- The type of the data to hide.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<TValue>
- The EdgeDataKey<TValue> for the item data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
dataKey
is null.
Hides the item data registered for the graph with the specified NodeLabelDataKey<TValue>.
Type Parameters
- TValue
- The type of the data to hide.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> for the item data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
dataKey
is null.
Hides the item data registered for the graph with the specified EdgeLabelDataKey<TValue>.
Type Parameters
- TValue
- The type of the data to hide.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> for the item data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
dataKey
is null.
Hides the nullable data registered for the graph with the specified ValueDataKey<TValue>.
Type Parameters
- TValue
- The type of the nullable data to hide.
Parameters
A map of options to pass to the method.
- key - ValueDataKey<TValue>
- The ValueDataKey<TValue> for the nullable data to hide.
Returns
- ↪RestoreToken
- A RestoreToken object to restore the hidden data.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
key
is null.
Pops the top layer from the context.
Remarks
popLayer removes the top layer from the stack, undoing the changes applied by the most recent pushLayer call.
All data registered on the layer will be removed from the graph. This includes the data added with pushLayer using the LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.
Note that you should only pop a layer if you have previously pushed one.
See Also
pushLayer
(layoutData?: LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>) : RestoreTokenPushes a new layer onto the context, optionally applying layout data.
Remarks
Internally, LayoutGraphContext operates as a stack of layers. Each call to pushLayer adds a new layer to the top of this stack, allowing you to temporarily override the data in the context.
Use this method when you need to temporarily override the data associated with a specific key with custom data. If layoutData
is provided, the data defined within the layoutData
will be added to the graph.
Parameters
A map of options to pass to the method.
- layoutData - LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- An optional LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> to apply to the graph. The data defined within the
layoutData
will be added to the graph.
Returns
- ↪RestoreToken
- A RestoreToken that can be used to remove the layer.
See Also
Removes the data registered for the graph with the specified DataKey<TValue>.
Remarks
dataKey
. If it is desired that data with the dataKey
is not visible at all, then hiding should be used (see e.g. method hideData or hideItemData).Type Parameters
- TValue
- The type of the data registered with the
.
Parameters
A map of options to pass to the method.
- dataKey - DataKey<TValue>
- The DataKey<TValue> the data should be removed for.