C

ObjectBindings<TDataItem>

A container for providers for specified properties of an object that provide the values that can later be applied to these properties.
Inheritance Hierarchy

Remarks

ObjectBindings<TDataItem> are used in NodeCreator.styleBindings, EdgeCreator.styleBindings and LabelCreator. styleBindings and can be used to configure the properties of the INodeStyle, IEdgeStyle or ILabelStyle assigned to a node, edge or label.

The following sample shows how to use styleBindings to configure the style of a node:

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',
)

Type Parameters

TDataItem

The type of the data item these bindings will use to resolve the values from.

Members

Show:

Constructors

Methods

Registers another binding between the property with the propertyName and a provider that provides the value for this property.
When applyBindings is called later, each binding that was previously registered via addBinding is applied to the given target object:
  • First the provider is called which returns the new value of the property.
  • Second the property of the target object which matches the propertyName is determined.
  • Finally the value returned by the provider is set on this property.
final

Parameters

propertyName: string
The name of the property.
provider: function(TDataItem): TValue
The provider that will be evaluated during applyBindings.

See Also

API
applyBindings
Applies all bindings added earlier to the target using the dataItem in the provider of the binding.
Applying each binding involves several steps:
  • First, the provider of the binding is called with the dataItem and returns the new value of the property.
  • Second, the property of the target which matches the property name of the binding is determined.
  • Finally, the value returned by the provider is set on this property.
protected

Parameters

target: any
The target object to whose properties the bindings shall be applied.
dataItem: TDataItem
The data item the provider of each binding is called with.

See Also

API
addBinding