documentationfor yFiles for HTML 2.6

SingleItem<TItem>

Represents a single item of type TItem.

Inheritance Hierarchy
SingleItem

Remarks

Depending on which option is most convenient there are several ways to provide that item:

  • item – to directly provide a single item that's already known
  • source – to provide an IEnumerable<T> from which the first item is used. This is evaluated when running the algorithm and not before.
  • delegate – to provide a predicate that checks whether an item should be used. The first matching one is used.

Only a single property should ever be set. When setting multiple properties to a non-null value, some may be ignored and take precedence over others.

Functions, lists and constant values are automatically converted to SingleItem<TItem>s. For example:

// Item
new ShortestPath({ source: node1 })

// Predicate
new ShortestPath({ source: (node) => isSource(node) })

// Source
new ShortestPath({ source: graphComponent.selection.selectedNodes })

Furthermore, the conversion supports a parameter object to initialize the properties. For example:

// Create a new SingleItem from a JavaScript Map and initialize its 'item' with the given element.
// This also works for the different properties as well.
const singleItemFromItem = SingleItem.from({
  item: graph.nodes.first()
})

// Or, instead of providing the specific property, the 'includes' key can be used
const singleItemFromInclude = SingleItem.from({
  includes: graph.nodes.first()
})

Type Parameters

TItem
The type of the single item.

Type Details

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

See Also

Constructors

Properties

Static Methods