List
Type class
A List class is used to hold a number of indexed items of the same type.
Sources
List can be used (imported) via one of the following packages.
/** * Import from: "core.ts" * Use like: am4core.List */import * as am4core from "@amcharts/amcharts4/core";/** * Include via: <script src="core.js"></script> * Access items like: am4core.List */Inheritance
List does not extend any other symbol.
List is extended by ListTemplate.
Properties
eventsType
EventDispatcher<AMEvent<this,IListEvents<T>>>Defaultnew EventDispatcher()Event dispatcher.
lengthType
numberNumber of items in list.
valuesType
Array<T>An array of values in the list.
Do not use this property to add values. Rather use dedicated methods, like
push(),removeIndex(), etc.
Methods
[Symbol.iterator]()Returns
Iterator<T>Returns an ES6 iterator for the list.
clear()Returns
voidRemoves all items from the list.
constructor(initial:Array<T>)Returns
ListConstructor
contains(value:T)Returns
booleanChecks if list contains specific item reference.
copyFrom(source:this)Returns
voidCopies and adds items from abother list.
each(f: (value:T, index:number) =>void)Returns
voidCalls
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|undefinedReturns an item at specified index.
hasIndex(index:number)Returns
booleanChecks if there's a value at specific index.
indexOf(value:T)Returns
numberSearches the list for specific item and returns its index.
insertIndex(index:number,
value:T)Returns
voidAdds an item to the list at a specific index, which pushes all the other items further down the list.
iterator()Returns
Iterator<T>Returns a list iterator.
moveValue(value:T,
toIndex?:number)Returns
voidMoves 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>Returns the last item from the list, and removes it.
push(value:K)Returns
KAdds an item to the end of the list.
pushAll(values:Array<T>)Returns
voidAdds multiple items to the list.
removeIndex(index:number)Returns
TRemoves a value at specific index.
removeValue(value:T)Returns
voidRemoves specific item from the list.
setAll(newArray:Array<T>)Returns
voidSets multiple items to the list.
All current items are removed.
setIndex(index:number,
value:T)Returns
TSets value at specific index.
If there's already a value at the index, it is overwritten.
shift()Returns
$type.Optional<T>Returns the first item from the list, and removes it.
sort(order: (left:T, right:T) =>Ordering)Returns
voidReorders list items according to specific ordering function.
swap(a:number,
b:number)Returns
voidSwaps indexes of two items in the list.
unshift(value:T)Returns
voidAdds an item as a first item in the list.
Events
insertedParam { type:
"inserted", target:List, newValue:A}Invoked when item is added to the list.
insertIndexParam { type:
"insertIndex", target:List, index:number, newValue:A}Invoked when
insertIndexmethod is called.removedParam { type:
"removed", target:List, oldValue:A}Invoked when item is removed from the list.
removeIndexParam { type:
"removeIndex", target:List, index:number, oldValue:A}Invoked when item is removed.
setAllParam { type:
"setAll", target:List, newArray:Array<A>, oldArray:Array<A> }Invoked when
setAllmethod is called.setIndexParam { type:
"setIndex", target:List, index:number, newValue:A, oldValue:A}Invoked when
setIndexmethod is called.