Populates a graph from custom data.
Remarks
This class can be used when the data consists of one or more collections of nodes, edges, and optionally, groups. The methods createNodesSource, createGroupNodesSource, and createEdgesSource bind the data to source objects from which nodes, groups, and edges will be created.
Generally, using the GraphBuilder class consists of a few basic steps:
- Create a GraphBuilder and optionally, provide an IGraph on which it should operate.
const graphBuilder = new GraphBuilder(graph)
- Create one or more
sources
from which the GraphBuilder should create the graph structure (createNodesSource, createGroupNodesSource, createEdgesSource).To create edges from the data, provide sourceIdProvider and targetIdProvider with createEdgesSource and a respective
idProvider
for the NodesSource<TDataItem> to tell the GraphBuilder how the data is structured.const nodesData = getNodesData() const nodesSource = graphBuilder.createNodesSource( nodesData, // nodes data (nodeDataItem) => nodeDataItem.nodeId, // node id provider ) const edgesData = getEdgesData() const edgesSource = graphBuilder.createEdgesSource( edgesData, (edgeDataItem) => edgeDataItem.sourceNodeId, (edgeDataItem) => edgeDataItem.targetNodeId, )
- Each NodesSource<TDataItem> provides a NodeCreator<TDataItem> that allows for further specification of how the items from this source should be created. You can provide defaults for the default styling but also bind more specific styling based on the actual data item with the styleProvider and styleBindings.
nodesSource.nodeCreator.defaults.shareStyleInstance = false nodesSource.nodeCreator.defaults.style = new ShapeNodeStyle({ stroke: 'darkOrange', fill: 'lightYellow', shape: 'round-rectangle', }) nodesSource.nodeCreator.styleBindings.addBinding( 'stroke', (employee) => employee.position.includes('Chief') ? 'darkRed' : 'darkOrange', ) nodesSource.nodeCreator.styleBindings.addBinding('shape', (employee) => employee.freelancer ? 'hexagon' : 'roundRectangle', )
It also allows for applying layout information from the data item ( layoutProvider), as well as further specification of the created node's tag ( tagProvider).
- Similarly, each EdgesSource<TDataItem> provides an EdgeCreator<TDataItem> that allows for specifying the styling of the created items (defaults, styleProvider, and styleBindings).
edgesSource.edgeCreator.defaults.style = new PolylineEdgeStyle({ smoothingLength: 20, })
Furthermore, it allows for obtaining bend locations from the data item ( bendsProvider), as well as further specification of the created edge's tag ( tagProvider).
edgesSource.edgeCreator.bendsProvider = (edgeDataItem) => edgeDataItem.bendPoints
- Optionally, labels can be added by providing one or multiple label bindings. If there is a varying number of labels per node, createLabelsSource can be used, instead. Similar methods are also available on the EdgeCreator<TDataItem>.
The LabelsSource<TDataItem> provides a LabelCreator<TDataItem> that allows for adjusting all aspects of the label creation, like style, text, size, and tag.
const edgeLabelCreator = edgesSource.edgeCreator.createLabelBinding( (edgeDataItem) => edgeDataItem.name, ) edgeLabelCreator.defaults.style = new LabelStyle({ backgroundFill: 'rgb(225,242,253)', backgroundStroke: 'lightskyblue', textSize: 8, })
- Call buildGraph to populate the graph. You can apply a layout algorithm afterward to make the graph look nice.
// Build a graph initially graphBuilder.buildGraph() // Apply a layout in a subsequent step graph.applyLayout(new OrganicLayout())
- If your items or collections change later, call updateGraph to make the changes visible in the graph. If the data item instances have changed, you can call setData or setData.
// Set the new data collections: graphBuilder.setData(nodesSource, getNodesData()) graphBuilder.setData(edgesSource, getEdgesData()) // Update a graph after the business data has changed graphBuilder.updateGraph() // Apply a layout in a subsequent step graph.applyLayout(new OrganicLayout())
Group nodes can be defined in three ways depending on the data:
- As a separate list, with each entry in the list defining a group node and an ID. The child nodes belonging to a group node define the ID of their group node as the parent ID.
graphBuilder.createGroupNodesSource( groupNodesData, (groupNodeData) => groupNodeData.nodeId, ) const nodesSource = graphBuilder.createNodesSource( nodesData, (nodeData) => nodeData.nodeId, ) nodesSource.parentIdProvider = (nodeData) => nodeData.parentId
- As a recursive hierarchical structure. That is, a group's data also includes a list of its children's data which is defined as createChildNodesSource. Note that a child can have children on its own.
const topLevelNodesSource = graphBuilder.createNodesSource( topLevelNodesData, (data) => data.nodeId, ) const childNodeSource = topLevelNodesSource.createChildNodesSource( (data) => data.children, ) childNodeSource.addChildNodesSource( (child) => child.children, childNodeSource, )
- As a group node which is implicitly defined on one or more of its children. Parent nodes can be defined as createParentNodesSource.
const leafNodesSource = graphBuilder.createNodesSource( leafNodesData, (data) => data.nodeId, ) const parentSource = leafNodesSource.createParentNodesSource( (data) => data.parent, )
You can further customize how nodes, groups, and edges are created by adding event handlers to the various events and modifying the items there. This can be used to modify items in ways that are not directly supported by the available bindings or defaults. There are creation and update events for all items, which allow for separate customization when nodes, groups, and edges are created or updated. For completely static graphs, where updateGraph is not needed, the update events can be safely ignored.
Related Reading in the Developer's Guide
GraphBuilder
, in particular, is topic of section GraphBuilder.Type Details
- yFiles module
- view
See Also
This class serves as a convenient way to create general graphs. Some aspects to look out for:
- buildGraph does not clear the graph. If needed, call clear to empty the graph before building it anew.
- The GraphBuilder ignores and preserves items manually created on the graph in between calls to updateGraph.
If you need to extensively modify your data in order to fit the requirements of the GraphBuilder, it is often better to write the code interfacing with the graph by hand instead of relying on GraphBuilder.
update
methods on the creators
(e.g. updateStyle), resolves the provider
(e.g. styleProvider) and applies the bindings
(e.g. applyStyleBindings). The latter can also be applied solely.For example, to update any aspect of node creation:
// configure the NodeCreator to update non-structural aspects
nodesSource.nodeCreator.addEventListener('node-updated', (evt) => {
nodesSource.nodeCreator.updateLayout(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateStyle(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateTag(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateLabels(evt.graph, evt.item, evt.dataItem)
})
builder.updateGraph()
Constructors
Initializes a new instance of the GraphBuilder class that operates on the given graph.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- nodes - any[]
- An array with configurations for NodesSource<TDataItem>s. Calls createNodesSource for each item.
- edges - any[]
- An array with configurations for EdgesSource<TDataItem>s. Calls createEdgesSource for each item.
Properties
Gets the graph used by this builder.
Remarks
Methods
addEdgesSource
<TDataItem>(data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>, edgesSource: EdgesSource<TDataItem>)Binds a collection of data items to the given edgesSource
.
Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects that is bound to the source.
- edgesSource - EdgesSource<TDataItem>
- The source to which the data is bound.
addNodesSource
<TDataItem>(data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>, nodesSource: NodesSource<TDataItem>)Binds a collection of data items to the given nodesSource
.
Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects that is bound to the source.
- nodesSource - NodesSource<TDataItem>
- The source to which the data is bound.
Populates the graph with items generated from the bound data.
Remarks
Returns
See Also
createEdgesSource
<TDataItem>(data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>, sourceId: function(TDataItem):any, targetId: function(TDataItem):any, id?: function(TDataItem, any):any) : EdgesSource<TDataItem>Creates a new EdgesSource<TDataItem> and binds a collection of edge data items to it.
Remarks
Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects to iterate and create the edges from.
- sourceId - function(TDataItem):any
- A provider that defines the source of the edge in the graph structure. Must resolve to the specified node id.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- targetId - function(TDataItem):any
- A provider that defines the target of the edge in the graph structure. Must resolve to the specified node id.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- id - function(TDataItem, any):any
- An optional function that yields an id for each element in the
data
. This id is used to identify the edges during updateGraph.Signature Details
function(dataItem: TDataItem, canonicalId: any) : any
A callback that provides an unique identifier for thedataItem
.id provider are used in NodesSource.idProvider, EdgesSource.idProvider and LabelsSource. idProvider to identify the created nodes, edges, and labels and avoid duplicate creation of items with the same ID.
The ID can also be used by parentIdProvider and sourceIdProvider and targetIdProvider to resolve the parent, source, or target nodes.
The ID is further used to identify nodes, edges, and labels during updateGraph.
Parameters
- dataItem - TDataItem
- The value that will be passed in.
- canonicalId - any
- The original canonical id of the value. For data arrays and iterables this is the index into the collection. For Maps and data objects this is the key associated with a value.
Returns
- any
- defaults - IEdgeDefaults
- A set of IEdgeDefaults that will be used for the edges and edge labels. This option either sets the value directly or recursively sets properties to the instance of the defaults property on the created object.
- style - function(TDataItem):IEdgeStyle
- An optional provider of an IEdgeStyle instance that will be used as the edge's style for the source data item. This option sets the styleProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : IEdgeStyle
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- tag - function(TDataItem):any
- An optional provider of an object that will be used as the edge's tag for the source data item. This option sets the tagProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- bends - function(TDataItem):IEnumerable<Point>
- An optional provider of an object that will be used as the edge's bends locations for the source data item. This option sets the bendsProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : IEnumerable<Point>
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- styleBindings - ObjectBindings<TDataItem>
- An optional set of bindings that will be applied to the edge's style. This option sets the styleBindings property on the created object.
- labels - function(TDataItem):string[]
- An array of label bindings which are added to the newly created EdgesSource<TDataItem>.
Signature Details
function(dataItem: TDataItem) : string
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- string
Returns
- ↪EdgesSource<TDataItem>
- A new EdgesSource<TDataItem> instance that can be used to further customize the creation of edges, e.g. provide specific style defaults.
createGroupNodesSource
<TDataItem>(data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>, id: function(TDataItem, any):any) : NodesSource<TDataItem>Creates a new NodesSource<TDataItem> and binds a collection of group node data items to it.
Remarks
The NodeCreator<TDataItem> of the returned NodesSource<TDataItem> can be used to further specify creation properties of these items, e.g. style, layout, etc.
Data items of this collection are created as group nodes in the graph.
Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects to iterate and create the group nodes from.
- id - function(TDataItem, any):any
- A function that yields an ID for each element in the
data
. If the data has no associated IDs,null
may be used as well in which case the builder uses the objects themselves as identifiers internally.
This ID is used by parentIdProvider and sourceIdProvider and targetIdProvider to resolve the parent, source, or target nodes. The ID is also used to identify nodes during updateGraph.Signature Details
function(dataItem: TDataItem, canonicalId: any) : any
A callback that provides an unique identifier for thedataItem
.id provider are used in NodesSource.idProvider, EdgesSource.idProvider and LabelsSource. idProvider to identify the created nodes, edges, and labels and avoid duplicate creation of items with the same ID.
The ID can also be used by parentIdProvider and sourceIdProvider and targetIdProvider to resolve the parent, source, or target nodes.
The ID is further used to identify nodes, edges, and labels during updateGraph.
Parameters
- dataItem - TDataItem
- The value that will be passed in.
- canonicalId - any
- The original canonical id of the value. For data arrays and iterables this is the index into the collection. For Maps and data objects this is the key associated with a value.
Returns
- any
- parentId - function(TDataItem):any
- A provider that yields a parent id for each element of the associated data collection in the GraphBuilder. This option sets the parentIdProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- defaults - INodeDefaults
- A set of INodeDefaults that will be used for the nodes and node labels. This option either sets the value directly or recursively sets properties to the instance of the defaults property on the created object.
- layout - function(TDataItem):Rect
- An optional provider of a Rect that will be used as the node's layout for the source data item. This option sets the layoutProvider property on the created object.
- style - function(TDataItem):INodeStyle
- An optional provider of an INodeStyle instance that will be used as the node's style for the source data item. This option sets the styleProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : INodeStyle
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- tag - function(TDataItem):any
- An optional provider of an object that will be used as the node's tag for the source data item. This option sets the tagProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- styleBindings - ObjectBindings<TDataItem>
- An optional set of bindings that will be applied to the node's style. This option sets the styleBindings property on the created object.
- layoutBindings - ObjectBindings<TDataItem>
- An optional set of bindings that will be applied to the node's layout. This option sets the layoutBindings property on the created object.
- labels - function(TDataItem):string[]
- An array of label bindings which are added to the newly created NodesSource<TDataItem>.
Signature Details
function(dataItem: TDataItem) : string
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- string
Returns
- ↪NodesSource<TDataItem>
- A new NodesSource<TDataItem> instance that can be used to further customize the creation of nodes, e.g. provide specific style defaults.
createNodesSource
<TDataItem>(data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>, id: function(TDataItem, any):any) : NodesSource<TDataItem>Creates a new NodesSource<TDataItem> and binds a collection of node data items to it.
Remarks
Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects to iterate and create the nodes from.
- id - function(TDataItem, any):any
- A function that yields an ID for each element in the
data
. If the data has no associated IDs,null
may be used as well in which case the builder uses the objects themselves as identifiers internally.
This ID is used by parentIdProvider and sourceIdProvider and targetIdProvider to resolve the parent, source, or target nodes. The ID is also used to identify nodes during updateGraph.Signature Details
function(dataItem: TDataItem, canonicalId: any) : any
A callback that provides an unique identifier for thedataItem
.id provider are used in NodesSource.idProvider, EdgesSource.idProvider and LabelsSource. idProvider to identify the created nodes, edges, and labels and avoid duplicate creation of items with the same ID.
The ID can also be used by parentIdProvider and sourceIdProvider and targetIdProvider to resolve the parent, source, or target nodes.
The ID is further used to identify nodes, edges, and labels during updateGraph.
Parameters
- dataItem - TDataItem
- The value that will be passed in.
- canonicalId - any
- The original canonical id of the value. For data arrays and iterables this is the index into the collection. For Maps and data objects this is the key associated with a value.
Returns
- any
- parentId - function(TDataItem):any
- A provider that yields a parent id for each element of the associated data collection in the GraphBuilder. This option sets the parentIdProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- defaults - INodeDefaults
- A set of INodeDefaults that will be used for the nodes and node labels. This option either sets the value directly or recursively sets properties to the instance of the defaults property on the created object.
- layout - function(TDataItem):Rect
- An optional provider of a Rect that will be used as the node's layout for the source data item. This option sets the layoutProvider property on the created object.
- style - function(TDataItem):INodeStyle
- An optional provider of an INodeStyle instance that will be used as the node's style for the source data item. This option sets the styleProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : INodeStyle
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- tag - function(TDataItem):any
- An optional provider of an object that will be used as the node's tag for the source data item. This option sets the tagProvider property on the created object.
Signature Details
function(dataItem: TDataItem) : any
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- any
- styleBindings - ObjectBindings<TDataItem>
- An optional set of bindings that will be applied to the node's style. This option sets the styleBindings property on the created object.
- layoutBindings - ObjectBindings<TDataItem>
- An optional set of bindings that will be applied to the node's layout. This option sets the layoutBindings property on the created object.
- labels - function(TDataItem):string[]
- An array of label bindings which are added to the newly created NodesSource<TDataItem>.
Signature Details
function(dataItem: TDataItem) : string
A callback that provides an instance of typeTValue
for the givendataItem
.Parameters
- dataItem - TDataItem
- The data item for which a value shall be provided.
Returns
- string
Returns
- ↪NodesSource<TDataItem>
- A new NodesSource<TDataItem> instance that can be used to further customize the creation of nodes, e.g. provide specific style defaults.
Returns the data item the given node
was created for.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node that was created for the data item.
Returns
- ↪any?
- The data item the given
node
was created for.
Returns the data item the given edge
was created for.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that was created for the data item.
Returns
- ↪any?
- The data item the given
edge
was created for.
Returns the IEdge that was created for a data item with the given id
.
Remarks
Type Parameters
- TId
- The type of the id.
Parameters
A map of options to pass to the method.
- id - TId
- The id the edge was created for.
Returns
Returns the IEdge that was created for the given item
.
Remarks
Type Parameters
- TDataItem
- The type of the data item.
Parameters
A map of options to pass to the method.
- item - TDataItem
- The data item the edge was created for.
Returns
Returns the INode that was created for a data item with the given id
.
Remarks
Type Parameters
- TId
- The type of the id.
Parameters
A map of options to pass to the method.
- id - TId
- The id the node was created for.
Returns
Returns the INode that was created for the given item
.
Remarks
Type Parameters
- TDataItem
- The type of the data item.
Parameters
A map of options to pass to the method.
- item - TDataItem
- The data item the node was created for.
Returns
Triggers the edge-created event.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that has been created.
- dataItem - any
- The data item from which the edge has been created.
Triggers the edge-removed event.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that has been removed.
- dataItem - any
- The corresponding data item of the removed edge.
Triggers the edge-updated event.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that has been updated.
- dataItem - any
- The data item with which the edge has been updated.
Triggers the label-added event.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has been added.
- dataItem - any
- The data item from which the label has been created.
Triggers the label-removed event.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has been removed.
- dataItem - any
- The corresponding data item of the removed label.
Triggers the label-updated event.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has been updated.
- dataItem - any
- The data item with which the label has been updated.
Triggers the node-created event.
Parameters
A map of options to pass to the method.
- node - INode
- The node that has been created.
- dataItem - any
- The data item from which the node has been created.
Triggers the node-removed event.
Parameters
A map of options to pass to the method.
- node - INode
- The node that has been removed.
- dataItem - any
- The corresponding data item of the removed node.
Triggers the node-updated event.
Parameters
A map of options to pass to the method.
- node - INode
- The node that has been updated.
- dataItem - any
- The data item with which the node has been updated.
setData
<TDataItem>(nodesSource: NodesSource<TDataItem>, data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>)Binds a new data collection to a NodesSource<TDataItem>, replacing the old one.
Remarks
nodesSource
, such that updateGraph considers the new collection.Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- nodesSource - NodesSource<TDataItem>
- The source whose data source should be reassigned.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects that is specified for the given source.
setData
<TDataItem>(edgesSource: EdgesSource<TDataItem>, data: TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>)Binds a new data collection to a EdgesSource<TDataItem>, replacing the old one.
Remarks
edgesSource
, such that updateGraph considers the new collection.Type Parameters
- TDataItem
- The type of the data items in the source.
Parameters
A map of options to pass to the method.
- edgesSource - EdgesSource<TDataItem>
- The source whose data source should be reassigned.
- data - TDataItem[] | Iterable<TDataItem> | Map<any,TDataItem> | { [id: string]: TDataItem; } | (() => Generator<TDataItem>
- The collection of objects that is specified for the given source.
Updates the graph after changes in the bound data.
Remarks
update
methods on the creators
(e.g. updateStyle), resolves the provider
(e.g. styleProvider) and applies the bindings
(e.g. applyStyleBindings). The latter can also be applied solely.For example, to update any aspect of node creation:
// configure the NodeCreator to update non-structural aspects
nodesSource.nodeCreator.addEventListener('node-updated', (evt) => {
nodesSource.nodeCreator.updateLayout(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateStyle(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateTag(evt.graph, evt.item, evt.dataItem)
nodesSource.nodeCreator.updateLabels(evt.graph, evt.item, evt.dataItem)
})
builder.updateGraph()
Events
Occurs when an edge has been created by any one of the edges sources.
Remarks
This event can be used to further customize the created node.
New edges are created either in response to calling buildGraph, or in response to calling updateGraph when there are new items in the edges sources.
See Also
Occurs when an edge has been removed.
Remarks
This event can be used to further customize the created node.
Edges are removed in response to calling updateGraph.
See Also
Occurs when an edge has been updated.
Remarks
This event can be used to further customize the created node.
Edges are updated in response to calling updateGraph.
See Also
Occurs when a label has been added to a node or edge.
Remarks
This event can be used to further customize the created label.
New labels are added in response to calling buildGraph, or in response to calling updateGraph.
See Also
Occurs when a node or edge label has been removed.
Remarks
This event can be used to further customize the created label.
Labels are removed in response to calling updateGraph.
See Also
Occurs when a node or edge label has been updated.
Remarks
This event can be used to further customize the created label.
Labels are updated in response to calling updateGraph.
See Also
Occurs when a node has been created by any one of the nodes sources.
Remarks
This event can be used to further customize the created node.
New nodes are created either in response to calling buildGraph, or in response to calling updateGraph when there are new items in the nodes sources.
See Also
Occurs when a node has been removed from any one of the nodes sources.
Remarks
This event can be used to further customize the created node.
Nodes are removed in response to calling updateGraph.
See Also
Occurs when a node has been updated.
Remarks
This event can be used to further customize the created node.
Nodes are updated in response to calling updateGraph.