Interface used by IGraph and the like to declare and obtain the defaults for labels.
Inheritance Hierarchy
ILabelDefaults
Remarks
Note that changing these defaults does not change properties of already created model items. Rather, only items created after the change are affected.
Examples
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.ILabelDefaults
See Also
INodeDefaults.labels,
IEdgeDefaults.labels,
IGraph.nodeDefaults,
IGraph.edgeDefaults,
IGraph.groupNodeDefaults,
Placing Labels,
Setting Defaults for new Items
Properties
Gets or sets a property that determines whether to automatically adjust the preferred size of a label.
Remarks
On a call to setLabelText or setStyle, the preferred size of the label will automatically be adjusted to the preferred size that is suggested by the label's style renderer, if this property is set to true.
Examples
const node = graph.createNodeAt(new Point(0, 0))
const label = graph.addLabel(node, 'Text')
const preferredSize1 = label.preferredSize
// enable auto adjust
graph.nodeDefaults.labels.autoAdjustPreferredSize = true
graph.setLabelText(label, 'Another Label Text')
const preferredSize2 = label.preferredSize
// preferred size has been adjusted to changed text
console.log(preferredSize1.equals(preferredSize2)) // false
// disable auto adjust
graph.nodeDefaults.labels.autoAdjustPreferredSize = false
graph.setLabelText(label, 'x')
const preferredSize3 = label.preferredSize
// preferred size has not been adjusted to changed text
console.log(preferredSize2.equals(preferredSize3)) // true
// adjusting the preferred size can be triggered manually, though
graph.adjustLabelPreferredSize(label)
See Also
Gets or sets the label model parameter to use for labels.
Remarks
Depending on the setting of shareLayoutParameterInstance, the getLayoutParameterInstance method should return a clone of this instance or the very same instance.
Examples
graph.nodeDefaults.labels.layoutParameter = InteriorLabelModel.CENTER
graph.nodeDefaults.labels.style = new DefaultLabelStyle()
See Also
Gets or sets the style to use for labels.
Remarks
Depending on the setting of shareStyleInstance, the getStyleInstance method should return a clone of this instance or the very same instance.
Examples
graph.nodeDefaults.labels.layoutParameter = InteriorLabelModel.CENTER
graph.nodeDefaults.labels.style = new DefaultLabelStyle()
See Also
Methods
Factory method that returns a label model parameter instance for use with newly created labels.
Remarks
Most implementations will yield either, a clone of or the layoutParameter property, if shareLayoutParameterInstance is enabled, but they might use more complicated logic, too.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- owner - ILabelOwner
- The owner of the label that will be created.
Returns
- ↪ILabelModelParameter
- The parameter to use, which for most implementations is either a clone of or the layoutParameter property, if shareLayoutParameterInstance is enabled.
Factory method that returns a style instance for use with newly created labels.
Remarks
Most implementations will yield either, a clone of or the style property, if shareStyleInstance is enabled, but they might use more complicated logic, too.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- owner - ILabelOwner
- The owner of the label that will be created.
Returns
- ↪ILabelStyle
- The style to use, which for most implementations is either a clone of or the style property, if shareStyleInstance is enabled.