documentationfor yFiles for HTML 2.6

ItemMapping<TItem,TValue>

Provides different ways to define a mapping from items to values for use with LayoutData.

Remarks

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

This class supports LayoutData implementations and does not usually have to be instantiated by client code explicitly. Instances of this class are properties of concrete LayoutData implementations.

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

// Constant
new HierarchicLayoutData({
  sourcePortCandidates: [
    PortCandidate.createCandidate('east', 0),
    PortCandidate.createCandidate('west', 0)
  ]
})

// Delegate
new HierarchicLayoutData({
  sourcePortCandidates: () =>
    ICollection.from(
      east
        ? [PortCandidate.createCandidate('east', 0)]
        : [PortCandidate.createCandidate('west', 0)]
    )
})

// Mapper
new HierarchicLayoutData({ sourceGroupIds: new Mapper() })
// or a JavaScript Map
new HierarchicLayoutData({ sourceGroupIds: new Map() })

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

// Create a new ItemMapping from a JavaScript Map and initialize its 'mapper' with the new Map.
// This also works for the different properties as well.
const mappingFromMapper = ItemMapping.from({
  mapper: new Map()
})
// Or, instead of providing the specific property, the 'includes' key can be used
const mappingWithIncludes = ItemMapping.from({
  includes: new Map()
})

Type Parameters

TItem
The type of the items that are mapped.
TValue
The type of the values the items are mapped to.

Type Details

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

See Also

Constructors

Properties

Static Methods