C

NodesSource<TDataItem>

A class that accepts a collection of objects from the GraphBuilder to build INodes from.
Inheritance Hierarchy

Remarks

It manages the structural aspects of the graph creation, while the associated nodeCreator is responsible for the properties of the created items.

Type Parameters

TDataItem

The type of the data items in the source.

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new source with the given nodeCreator.

Parameters

nodeCreator: NodeCreator<TDataItem>
The creator that is used to create the nodes of this source.
idProvider?: function(TDataItem, any): any
An optional function that yields an id for each element of the associated data collection in the GraphBuilder.

Properties

Gets or sets a provider that yields an id for each element of the associated data collection in the GraphBuilder.
Gets or sets the NodeCreator<TDataItem> for this source, which can be used to adjust the creation behavior.
Gets or sets a provider that yields a parent id for each element of the associated data collection in the GraphBuilder.
While this is optional, it is required to specify a parent/child node grouping relationship.
conversionfinal

See Also

Developer's Guide

Methods

Binds a collection of child data items to the given childNodesSource.
final

Parameters

childDataProvider: function(TDataItem): any
A function that yields a child data item for each element of the associated data collection in the GraphBuilder.
childNodesSource: NodesSource<TChildDataItem>
The child node source to which the child data is bound.
Binds a provider for parent data items to the given nodeSource.
final

Parameters

parentDataProvider: function(TDataItem): TParentDataItem
A function that yields a parent data item for each element of the associated data collection in the GraphBuilder.
nodeSource: NodesSource<TParentDataItem>
The node source to which the parent data is bound.
Registers a collection of child data items functioning as child entities for the NodeCreator<TChildDataItem> of the returned NodesSource<TChildDataItem>.

This method can be used when nested groups and their contents are to be generated from hierarchically structured data.

const topLevelNodesSource = graphBuilder.createNodesSource(
  topLevelNodesData,
  (data) => data.nodeId,
)
const childNodeSource = topLevelNodesSource.createChildNodesSource(
  (data) => data.children,
)
childNodeSource.addChildNodesSource(
  (child) => child.children,
  childNodeSource,
)

The node defaults of this newly created source cascade with the defaults of this source.

If an optional ID provider is used, the identifiers created by said function have to be unique for the elements in the given data set. Otherwise, the behavior of the buildGraph and the updateGraph methods is undefined.
final

Parameters

childDataProvider: function(TDataItem): any
A function that yields a child data item for each element of the associated data collection in the GraphBuilder.
idProvider?: function(TChildDataItem, any): any
An optional function that yields an id for each element of the associated data collection in the GraphBuilder.

Return Value

NodesSource<TChildDataItem>
A new NodesSource<TDataItem> instance that can be used to further customize the creation of child nodes, e.g. provide specific style defaults.

See Also

Developer's Guide
Registers a collection of data items functioning as implicit parent entities for the NodeCreator<TParentDataItem> of the returned NodesSource<TParentDataItem>.

This method can be used when a hierarchically structured graph should be created for this NodeSource without having to specify an explicit group node source.

const leafNodesSource = graphBuilder.createNodesSource(
  leafNodesData,
  (data) => data.nodeId,
)
const parentSource = leafNodesSource.createParentNodesSource(
  (data) => data.parent,
)

This method returns a new NodesSource<TDataItem> instance which can in turn serve as input for subsequent calls to createParentNodesSource, thus enabling the creation of multi-layered hierarchies.

Calling this method creates only the immediate parent group nodes for the items in this node source. To automatically create higher hierarchy levels, use addParentNodesSource on the newly created parent node source

const leafNodesSource = graphBuilder.createNodesSource(
  leafNodesData,
  (data) => data.nodeId,
)
const parentSource = leafNodesSource.createParentNodesSource(
  (data) => data.parent,
)
//Enable recursive ascent for the new parent source
parentSource.addParentNodesSource((data) => data.parent, parentSource)

The node defaults of this newly created source cascade with the defaults of this source.

final

Parameters

parentDataProvider: function(TDataItem): TParentDataItem
A function that yields a parent data item for each element of the associated data collection in the GraphBuilder.
idProvider?: function(TParentDataItem, any): any
An optional function that yields a unique id for each object returned by parentDataProvider. This allows to create stable hierarchies even if the actual data items are not referentially equal.

Return Value

NodesSource<TParentDataItem>
A new NodesSource<TDataItem> instance that can be used to further customize the creation of group nodes, e.g. provide specific style defaults.

See Also

Developer's Guide
API
addParentNodesSource
Optionally obtains the id for the parent or null given each data item for which a node is created.
This implementation uses the parentIdProvider to obtain the value from the data item.
protected

Parameters

dataItem: TDataItem
A single data item from the associated data collection in the GraphBuilder.

Return Value

any
The id of another node or null in case the node should be put in the root of the hierarchy.

See Also

API
parentIdProvider