documentationfor yFiles for HTML 2.6

DefaultLabelStyle

A basic label style which renders the label's text and optionally a background and border.

Inheritance Hierarchy
DefaultLabelStyle
Implemented Interfaces

Remarks

The style allows for setting text color, font, font size and font style. It also provides various text alignments and wrapping options.

This style uses a DefaultLabelStyleRenderer to create its visualization.

An optional background can be rendered. Different shapes, colors, and borders are supported.

Examples

const node1 = graph.createNode(new Rect(0, 0, 40, 40))
const node2 = graph.createNode(new Rect(100, 0, 40, 40))
const node3 = graph.createNode(new Rect(200, 0, 40, 40))

graph.addLabel(
  node1,
  'Text only',
  ExteriorLabelModel.SOUTH,
  new DefaultLabelStyle()
)

graph.addLabel(
  node2,
  'With borders',
  ExteriorLabelModel.SOUTH,
  new DefaultLabelStyle({
    backgroundStroke: 'darkslategray',
    backgroundFill: 'lightgray',
    shape: 'rectangle',
    insets: [0, 2]
  })
)

graph.addLabel(
  node3,
  'Longer texts can be wrapped automatically',
  ExteriorLabelModel.SOUTH,
  new DefaultLabelStyle({
    backgroundStroke: 'darkgoldenrod',
    backgroundFill: 'white',
    shape: 'rectangle',
    insets: [0, 2],
    verticalTextAlignment: 'center',
    horizontalTextAlignment: 'center'
  }),
  new Size(80, 80)
)

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.styles.DefaultLabelStyle

See Also

Constructors

Properties

Methods

Default Properties