Skip to content

ListTemplate

Type class

A version of a List that is able to create new elements as well as apply additional settings to newly created items.

More info: List templates

Sources

ListTemplate can be used (imported) via one of the following packages.

// Import ListTemplate
import * as am5 from "@amcharts/amcharts5";
// Create ListTemplate
am5.ListTemplate.new(root, {
// ... config if applicable
});

Inheritance

ListTemplate extends ListAutoDispose.

ListTemplate is not extended by any other symbol.

Properties

make

Type () => A

template

Type Template

4 inherited items
autoDispose

Type booleanDefault trueInherited from ListAutoDispose

Automatically disposes elements that are removed from the list.

events

Type EventDispatcherDefault new EventDispatcher()Inherited from List

length

Type numberInherited from List

Number of items in list.

values

Type ArrayInherited from List

An array of values in the list.

Don't change this array directly: use methods like push() and removeIndex(), which dispatch the list's events.

Methods

constructor(template: Template,
make: () => A
)

Returns ListTemplate

23 inherited items
[Symbol.iterator]()

Returns IteratorInherited from List

Returns an ES6 iterator for the list.

clear()

Returns voidInherited from List

Removes all items from the list.

contains(value: T)

Returns booleanInherited from List

Checks if list contains specific item reference.

copyFrom(source: this)

Returns voidInherited from List

Adds all items of another list to the end of this one.

dispose()

Returns voidInherited from ListAutoDispose

each(f: (value: T, index: number) => void)

Returns voidInherited from List

Calls f for each item in the list, with the item and its index.

eachReverse(f: (value: T, index: number) => void)

Returns voidInherited from List

Calls f for each item in the list, from last to first, with the item and its index.

getIndex(index: number)

Returns T | undefinedInherited from List

Returns an item at specified index.

hasIndex(index: number)

Returns booleanInherited from List

Checks if there's a value at specific index.

indexOf(value: T)

Returns numberInherited from List

Searches the list for specific item and returns its index.

insertIndex(index: number,
value: K
)

Returns KInherited from List

Inserts an item at index, moving the items from there on one place further.

isDisposed()

Returns booleanInherited from ListAutoDispose

moveValue(value: K,
toIndex?: undefined | number
)

Returns KInherited from List

Moves an item to toIndex, or to the end of the list if toIndex is not set. An item that is not in the list yet is added.

pop()

Returns OptionalInherited from List

Returns the last item from the list, and removes it.

push(value: K)

Returns KInherited from List

Adds an item to the end of the list.

pushAll(values: Array)

Returns voidInherited from List

Adds multiple items to the end of the list.

removeIndex(index: number)

Returns TInherited from List

Removes a value at specific index.

removeValue(value: T)

Returns voidInherited from List

Removes all copies of an item from the list.

setAll(newArray: Array)

Returns voidInherited from List

Replaces all items in the list with newArray.

setIndex(index: number,
value: T
)

Returns TInherited from List

Replaces the value at index, which must already exist.

shift()

Returns OptionalInherited from List

Returns the first item from the list, and removes it.

swap(a: number,
b: number
)

Returns voidInherited from ListAutoDispose

Swaps two items in the list, without disposing them.

unshift(value: K)

Returns KInherited from List

Adds an item as a first item in the list.

Events

Add event handlers to ListTemplate object using its events.on() method. Read about adding event handlers.

7 inherited items
clear

Param { type: "clear", target: ListTemplate, oldValues: Array }Inherited from List

All items were removed, by clear() or setAll().

insertIndex

Param { type: "insertIndex", target: ListTemplate, index: number, newValue: A }Inherited from List

An item was inserted at index.

moveIndex

Param { type: "moveIndex", target: ListTemplate, newIndex: number, oldIndex: number, value: A }Inherited from List

An item was moved from oldIndex to newIndex.

push

Param { type: "push", target: ListTemplate, newValue: A }Inherited from List

An item was added to the end of the list.

removeIndex

Param { type: "removeIndex", target: ListTemplate, index: number, oldValue: A }Inherited from List

The item at index was removed.

setIndex

Param { type: "setIndex", target: ListTemplate, index: number, newValue: A, oldValue: A }Inherited from List

The item at index was replaced.

swap

Param { type: "swap", target: ListTemplate, a: A, b: A }Inherited from List

Two items swapped places.