C

ItemMapping<TItem, TValue>

Provides different ways to define a mapping from items to values for use with LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> and analysis algorithms.
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 mapper<TItem, TValue>, mapperFunction<TItem, TValue> and constant<TItem, TValue> 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.

Members

No filters for this type

Properties

Gets or sets a constant value all items are mapped to.
Setting this property will override any previously set properties.
final
Gets or sets an IMapper<K, V> that realizes the mapping.
This property is initialized by default and the returned IMapper<K, V> can be used directly. Setting this property will override any previously set properties.
conversionfinal
Gets or sets a delegate that implements the mapper function.
Setting this property will override any previously set properties.
final
Function Details
A delegate that mimics the IMapper.get<K, V> access.
Parameters
key: TItem
The key of the mapping.
Return Value
TValue
The value or a suitable default that is associated with key.