documentationfor yFiles for HTML 2.6

NodeCreator<TDataItem>

This class can be used to create and update INodes based on data items.

Inheritance Hierarchy
NodeCreator

Remarks

These data items can be any business or arbitrary data which should be represented by nodes.

NodeCreator<TDataItem> allows for conveniently binding properties of the data item to the properties of the created INode to control aspects like layout and styling.

This class can be used both standalone as well as in conjunction with any of the GraphBuilders, e.g. GraphBuilder.

In the context of the GraphBuilder, it is responsible to create the items from the associated NodesSource<TDataItem>s.

Examples

A NodeCreator<TDataItem> can either be used with a NodesSource<TDataItem> in conjunction with a GraphBuilder

const builder = new GraphBuilder()
const nodesSource = builder.createNodesSource(
  nodeData,
  (nodeData) => nodeData.nodeId
)
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' : 'round-rectangle'
)

builder.buildGraph()

or it can be used standalone. In that case, its createNode method can be used to create nodes.

const nodeCreator = new NodeCreator()
nodeCreator.defaults.shareStyleInstance = true
nodeCreator.defaults.style = new ShapeNodeStyle({
  stroke: 'darkorange',
  fill: 'lightyellow',
  shape: 'round-rectangle'
})
nodeCreator.styleBindings.addBinding('stroke', (employee) =>
  employee.position.includes('Chief') ? 'darkred' : 'darkorange'
)
nodeCreator.styleBindings.addBinding('shape', (employee) =>
  employee.freelancer ? 'hexagon' : 'round-rectangle'
)

const node = nodeCreator.createNode(graph, null, dataItem)const nodeCreator = new NodeCreator<Employee>()
nodeCreator.defaults.shareStyleInstance = true
nodeCreator.defaults.style = new ShapeNodeStyle({
  stroke: 'darkorange',
  fill: 'lightyellow',
  shape: 'round-rectangle'
})
nodeCreator.styleBindings.addBinding('stroke', (employee) =>
  employee.position.includes('Chief') ? 'darkred' : 'darkorange'
)
nodeCreator.styleBindings.addBinding('shape', (employee) =>
  employee.freelancer ? 'hexagon' : 'round-rectangle'
)

const node = nodeCreator.createNode(graph, null, dataItem)

Type Parameters

TDataItem
The type of the data items in the source.

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.binding.NodeCreator

See Also

Constructors

Properties

Methods

Events