A container for providers for specified properties of an object that provide the values that can later be applied to these properties.
Inheritance Hierarchy
ObjectBindings
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.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.binding.ObjectBindings
Methods
Registers another binding between the property with the propertyName
and a provider
that provides the value for this property.
Remarks
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.
Type Parameters
- TValue
- The type of the property.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- propertyName - string
- The name of the property.
- provider - function(TDataItem):TValue
- The provider that will be evaluated during applyBindings.
Signature Details
function(dataItem: TDataItem) : TValue
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
- TValue
See Also
Applies all bindings added earlier to the target
using the dataItem
in the provider of the binding.
Remarks
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.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- target - Object
- The target object to whose properties the bindings shall be applied.
- dataItem - TDataItem
- The data item the provider of each binding is called with.