documentationfor yFiles for HTML 2.6

ContextItemMapping<TItem,TValue,TContext>

Provides different ways to define a mapping from items to values that takes a context object into consideration, too.

Inheritance Hierarchy

Remarks

Only one of the provided ways to define a mapping can be used at the same time, therefore only one of the properties contextDelegate, delegate, mapper, and constant should be set on each instance.

This class supports LayoutData implementations and does not usually have to be used explicitly.

Functions, IMapper<K,V>s and constant values are automatically converted to ContextItemMapping<TItem,TValue,TContext>s. For example:

// Constant
new PartitionGridData({ cellIds: partitionGrid.createCellId(0, 0) })

// Context Delegate
new PartitionGridData({ cellIds: (node, grid) => grid.createCellId(0, 0) })
// or
const grid = new PartitionGrid(4, 4)
new PartitionGridData({ cellIds: () => grid.createCellId(0, 0) })

// Mapper
new PartitionGridData({ cellIds: new Mapper() })
// or a JavaScript Map
new PartitionGridData({ cellIds: new Map() })

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 items that are mapped.
TValue
The type of the values the items are mapped to.
TContext
The type of the context passed to the

Type Details

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

Constructors

Properties

Static Methods