documentationfor yFiles for HTML 3.0.0.2

ItemMapping<TItem,TValue>

Provides different ways to define a mapping from items to values for use with LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.

Inheritance Hierarchy
ItemMapping

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, mapperFunction and constant should be set on each instance.

This class supports LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> implementations and does not usually have to be instantiated by client code explicitly. Instances of this class are properties of concrete LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> implementations.

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

// Constant
new HierarchicalLayoutData({
  sourceGroupIds: groupId,
})

// Delegate
new HierarchicalLayoutData({
  sourceGroupIds: (edge: IEdge) => edge.tag.sourceGroupId,
})

// Mapper
new HierarchicalLayoutData({ sourceGroupIds: new Mapper() })
// or a JavaScript Map
new HierarchicalLayoutData({ 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.
new HierarchicalLayoutData({
  sourceGroupIds: new Map(),
})
// Or, instead of providing the specific property, the 'includes' key can be used
new HierarchicalLayoutData({
  sourceGroupIds: {
    includes: new Map(),
  },
})

This class cannot be instantiated

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
algorithms

See Also

Properties