ListTemplate
Type class
A version of a List that has a "template".
A template is an instance of an object, that can be used to create new elements in the list without actually needing to create instances for those.
When new element is created in the list, e.g. by calling its create() method, an exact copy of the element is created (including properties and other attributes), inserted into the list and returned.
Sources
ListTemplate can be used (imported) via one of the following packages.
/** * Import from: "core.ts" * Use like: am4core.ListTemplate */import * as am4core from "@amcharts/amcharts4/core";/** * Include via: <script src="core.js"></script> * Access items like: am4core.ListTemplate */Inheritance
ListTemplate extends List.
ListTemplate is not extended by any other symbol.
Properties
templateType
TA "template" object to copy all properties from when creating new list items.
3 inherited items
eventsType
EventDispatcher<AMEvent<this,IListEvents<T>>>Defaultnew EventDispatcher()Inherited fromListEvent dispatcher.
lengthType
numberInherited fromListNumber of items in list.
valuesType
Array<T>Inherited fromListAn array of values in the list.
Do not use this property to add values. Rather use dedicated methods, like
push(),removeIndex(), etc.
Methods
clone()Returns
ListTemplate<T>Creates an exact clone of the list, including its items and template.
constructor(t:T)Returns
ListTemplateConstructor
copyFrom(source:this)Returns
voidCopies all elements from other list.
create(make: { })Returns
TInstantiates a new object of the specified type, adds it to the end of the list, and returns it.
21 inherited items
[Symbol.iterator]()Returns
Iterator<T>Inherited fromListReturns an ES6 iterator for the list.
clear()Returns
voidInherited fromListRemoves all items from the list.
contains(value:T)Returns
booleanInherited fromListChecks if list contains specific item reference.
each(f: (value:T, index:number) =>void)Returns
voidInherited fromListCalls
ffor each element in the list.fshould have at least one parameter defined which will get a current item, with optional second argument - index.getIndex(index:number)Returns
T|undefinedInherited fromListReturns an item at specified index.
hasIndex(index:number)Returns
booleanInherited fromListChecks if there's a value at specific index.
indexOf(value:T)Returns
numberInherited fromListSearches the list for specific item and returns its index.
insertIndex(index:number,
value:T)Returns
voidInherited fromListAdds an item to the list at a specific index, which pushes all the other items further down the list.
iterator()Returns
Iterator<T>Inherited fromListReturns a list iterator.
moveValue(value:T,
toIndex?:number)Returns
voidInherited fromListMoves an item to a specific index within the list.
If the index is not specified it will move the item to the end of the list.
pop()Returns
$type.Optional<T>Inherited fromListReturns the last item from the list, and removes it.
push(value:K)Returns
KInherited fromListAdds an item to the end of the list.
pushAll(values:Array<T>)Returns
voidInherited fromListAdds multiple items to the list.
removeIndex(index:number)Returns
TInherited fromListRemoves a value at specific index.
removeValue(value:T)Returns
voidInherited fromListRemoves specific item from the list.
setAll(newArray:Array<T>)Returns
voidInherited fromListSets multiple items to the list.
All current items are removed.
setIndex(index:number,
value:T)Returns
TInherited fromListSets value at specific index.
If there's already a value at the index, it is overwritten.
shift()Returns
$type.Optional<T>Inherited fromListReturns the first item from the list, and removes it.
sort(order: (left:T, right:T) =>Ordering)Returns
voidInherited fromListReorders list items according to specific ordering function.
swap(a:number,
b:number)Returns
voidInherited fromListSwaps indexes of two items in the list.
unshift(value:T)Returns
voidInherited fromListAdds an item as a first item in the list.
Events
6 inherited items
insertedParam { type:
"inserted", target:ListTemplate, newValue:A}Inherited fromListInvoked when item is added to the list.
insertIndexParam { type:
"insertIndex", target:ListTemplate, index:number, newValue:A}Inherited fromListInvoked when
insertIndexmethod is called.removedParam { type:
"removed", target:ListTemplate, oldValue:A}Inherited fromListInvoked when item is removed from the list.
removeIndexParam { type:
"removeIndex", target:ListTemplate, index:number, oldValue:A}Inherited fromListInvoked when item is removed.
setAllParam { type:
"setAll", target:ListTemplate, newArray:Array<A>, oldArray:Array<A> }Inherited fromListInvoked when
setAllmethod is called.setIndexParam { type:
"setIndex", target:ListTemplate, index:number, newValue:A, oldValue:A}Inherited fromListInvoked when
setIndexmethod is called.