documentationfor yFiles for HTML 2.6

The interface used in an IGraph implementation for labels.

Inheritance Hierarchy
Implemented Interfaces

Remarks

This interface provides read-only access to the properties of a label. In order to modify the state of an instance use the various methods provided by the IGraph this instance belongs to. Labels are stored in IListEnumerable<ILabel>s, that can be obtained from ILabelOwner implementations' labels property. Typical owners of a label are INode and IEdge instances. Like all items in an IGraph, this item supports the lookup method that can be used to query additional aspects of the item.

Examples

Working with a label in the graph
const graph = graphComponent.graph
const node = graph.createNodeAt(new Point(0, 0))

// add a label to the node
const label = graph.addLabel(node, 'Some Text', ExteriorLabelModel.SOUTH)

// the newly created label is part of the graph
console.log(graph.contains(label)) // true
console.log(graph.labels.size) // 1

// the label belongs to its owner
console.log(label.owner === node) // true
console.log(node.labels.size) // 1
console.log(node.labels.get(0) === label) // true

// removing the label removes it from the graph
graph.remove(label)
console.log(graph.contains(label)) // false
console.log(graph.labels.size) // 0
// and from its owner
console.log(label.owner === null) // true
console.log(node.labels.size) // 0
Labels cannot live without an owner in the graph
console.log(graph.contains(label)) // true
graph.remove(label.owner)
console.log(graph.contains(label)) // falseconsole.log(graph.contains(label)) // true
graph.remove(label.owner!)
console.log(graph.contains(label)) // false

Related Reading in the Developer's Guide

The graph model with all relevant types and their relationships is presented in detail in the section The Graph Model.

Using the look-up mechanism is explained in the section Service Locator Pattern: Lookup.

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.graph.ILabel

See Also

Properties

Methods