documentationfor yFiles for HTML 2.6

LabelingData

Specifies custom data for the GenericLabeling.

Inheritance Hierarchy
LayoutData
LabelingData

Examples

The following example shows how to create a new instance of LabelingData and use it with a GenericLabeling:

Creating an instance of LabelingData
const layoutData = new LabelingData()
layoutData.affectedLabels = graphComponent.selection.selectedLabels
layoutData.edgeLabelPreferredPlacement = (label) =>
  new PreferredPlacementDescriptor({
    // Place short labels horizontally, and others along the edge
    angleReference:
      label.text.length < 5
        ? LabelAngleReferences.ABSOLUTE
        : LabelAngleReferences.RELATIVE_TO_EDGE_FLOW
  })

graphComponent.graph.applyLayout(new GenericLabeling(), layoutData)const layoutData = new LabelingData()
layoutData.affectedLabels = graphComponent.selection.selectedLabels
layoutData.edgeLabelPreferredPlacement = (
  label: ILabel
): PreferredPlacementDescriptor =>
  new PreferredPlacementDescriptor({
    // Place short labels horizontally, and others along the edge
    angleReference:
      label.text.length < 5
        ? LabelAngleReferences.ABSOLUTE
        : LabelAngleReferences.RELATIVE_TO_EDGE_FLOW
  })

graphComponent.graph.applyLayout(new GenericLabeling(), layoutData)

In many cases the complete initialization of LabelingData can also be done in a single object initializer:

Using an object initializer for easy creation of LabelingData
const layoutData = new LabelingData({
  affectedLabels: graphComponent.selection.selectedLabels,
  edgeLabelPreferredPlacement: (label) =>
    new PreferredPlacementDescriptor({
      // Place short labels horizontally, and others along the edge
      angleReference:
        label.text.length < 5
          ? LabelAngleReferences.ABSOLUTE
          : LabelAngleReferences.RELATIVE_TO_EDGE_FLOW
    })
})

graphComponent.graph.applyLayout(new GenericLabeling(), layoutData)const layoutData = new LabelingData({
  affectedLabels: graphComponent.selection.selectedLabels,
  edgeLabelPreferredPlacement: (
    label: ILabel
  ): PreferredPlacementDescriptor =>
    new PreferredPlacementDescriptor({
      // Place short labels horizontally, and others along the edge
      angleReference:
        label.text.length < 5
          ? LabelAngleReferences.ABSOLUTE
          : LabelAngleReferences.RELATIVE_TO_EDGE_FLOW
    })
})

graphComponent.graph.applyLayout(new GenericLabeling(), layoutData)

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.labeling.LabelingData

See Also

Constructors

Properties

Methods