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
See Also
Developer's Guide
Members
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.
null for graphs that were not created via method createCopy.Gets or sets the LayoutAbortController used during the layout.
Methods
Registers a single value data for the graph with the specified ValueDataKey<TValue>.
dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- dataKey: ValueDataKey<TValue>
- The ValueDataKey<TValue> the data should be registered for.
- data: TValue
- The data to register.
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.
addItemConstantData
<TValue> (dataKey: NodeDataKey<TValue>, constantValue: TValue): IMapper<LayoutNode, TValue>dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- dataKey: NodeDataKey<TValue>
- The NodeDataKey<TValue> the data should be registered for.
- constantValue: TValue
- The value returned as data for all nodes.
Return Value
- 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.
addItemConstantData
<TValue> (dataKey: EdgeDataKey<TValue>, constantValue: TValue): IMapper<LayoutEdge, TValue>dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- dataKey: EdgeDataKey<TValue>
- The EdgeDataKey<TValue> the data should be registered for.
- constantValue: TValue
- The value returned as data for all edges.
Return Value
- 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>.
dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- 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.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- 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.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- 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.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Parameters
- 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.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
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.
Parameters
- 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.
- setter?: function(LayoutNode, TValue): void
- A callback to set the data for a node in the created mapper.
Return Value
- 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>.
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.
Parameters
- 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.
- setter?: function(LayoutEdge, TValue): void
- A callback to set the data for an edge in the created mapper.
Return Value
- 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>.
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.
Parameters
- 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.
- setter?: function(LayoutNodeLabel, TValue): void
- A callback to set the data for a node label in the created mapper.
Return Value
- 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>.
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.
Parameters
- 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.
- setter?: function(LayoutEdgeLabel, TValue): void
- A callback to set the data for an edge label in the created mapper.
Return Value
- 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>.
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.
Parameters
- dataKey: ValueDataKey<TValue>
- The ValueDataKey<TValue> for retrieving the data.
Return Value
- TValue
- The single value data registered for the graph with the specified
dataKey, ornullif 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>.
dataKey, this method recursively searches the underlying layers for data associated with the dataKey.Parameters
- dataKey: NodeDataKey<TValue>
- The NodeDataKey<TValue> for retrieving the IMapper<K, V>.
Return Value
- 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>.
dataKey, this method recursively searches the underlying layers for data associated with the dataKey.Parameters
- dataKey: EdgeDataKey<TValue>
- The EdgeDataKey<TValue> for retrieving the IMapper<K, V>.
Return Value
- 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>.
dataKey, this method recursively searches the underlying layers for data associated with the dataKey.Parameters
- dataKey: NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> for retrieving the IMapper<K, V>.
Return Value
- 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>.
dataKey, this method recursively searches the underlying layers for data associated with the dataKey.Parameters
- dataKey: EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> for retrieving the IMapper<K, V>.
Return Value
- 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.
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.
Parameters
- dataKey: ValueDataKey<TValue>
- The ValueDataKey<TValue> for retrieving the data.
Return Value
- TValue
- The single value data registered for the graph with the specified
dataKey, ornullif nothing is registered.
Hides the data registered for the graph with the specified ValueDataKey<TValue>.
Parameters
- key: ValueDataKey<TValue>
- The ValueDataKey<TValue> for the data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
keyis null.
Hides the item data registered for the graph with the specified NodeDataKey<TValue>.
Parameters
- dataKey: NodeDataKey<TValue>
- The NodeDataKey<TValue> for the item data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
dataKeyis null.
Hides the item data registered for the graph with the specified EdgeDataKey<TValue>.
Parameters
- dataKey: EdgeDataKey<TValue>
- The EdgeDataKey<TValue> for the item data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
dataKeyis null.
Hides the item data registered for the graph with the specified NodeLabelDataKey<TValue>.
Parameters
- dataKey: NodeLabelDataKey<TValue>
- The NodeLabelDataKey<TValue> for the item data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
dataKeyis null.
Hides the item data registered for the graph with the specified EdgeLabelDataKey<TValue>.
Parameters
- dataKey: EdgeLabelDataKey<TValue>
- The EdgeLabelDataKey<TValue> for the item data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden item data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
dataKeyis null.
Hides the nullable data registered for the graph with the specified ValueDataKey<TValue>.
Parameters
- key: ValueDataKey<TValue>
- The ValueDataKey<TValue> for the nullable data to hide.
Return Value
- RestoreToken
- A RestoreToken object to restore the hidden data.
Throws
- Exception ({ name: 'ArgumentError' })
- Thrown if
keyis null.
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
API
- pushLayer
pushLayer
(layoutData?: LayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>): RestoreTokenPushes a new layer onto the context, optionally applying layout data.
pushLayer
(layoutData?: LayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>): RestoreTokenInternally, 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
- layoutData?: LayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
- An optional LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> to apply to the graph. The data defined within the
layoutDatawill be added to the graph.
Return Value
- RestoreToken
- A RestoreToken that can be used to remove the layer.
See Also
API
- popLayer
Removes the data registered for the graph with the specified DataKey<TValue>.
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).Parameters
- dataKey: DataKey<TValue>
- The DataKey<TValue> the data should be removed for.