List

Type class

An ordered list of items that dispatches events as items are added, removed or moved.

Sources

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

// Import List
import * as am5 from "@amcharts/amcharts5";

// Create List
am5.List.new(root, {
  // ... config if applicable
});
<!-- Load List -->
<script src="index.js"></script>

<script>
// Create List
am5.List.new(root, {
  // ... config if applicable
});
</script>

Inheritance

List does not extend any other symbol.

List is extended by ListAutoDispose, Children, ListData.

Settings

List does not have any settings.

Private settings

List does not have any private settings.

Properties

events
#

Type EventDispatcher

Default new EventDispatcher()

length
#

Type number

Number of items in list.

@readonly

values
#

Type Array

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.

@readonly

Methods

[Symbol.iterator]()

#

Returns Iterator

Returns an ES6 iterator for the list.

clear()

#

Returns void

Removes all items from the list.

constructor(

initial: Array

)

#

Returns List

Constructor

contains(

value: T

)

#

Returns boolean

Checks if list contains specific item reference.

copyFrom(

source: this

)

#

Returns void

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

each(

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

)

#

Returns void

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

eachReverse(

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

)

#

Returns void

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

getIndex(

index: number

)

#

Returns T | undefined

Returns an item at specified index.

hasIndex(

index: number

)

#

Returns boolean

Checks if there's a value at specific index.

indexOf(

value: T

)

#

Returns number

Searches the list for specific item and returns its index.

insertIndex(

index: number,
value: K

)

#

Returns K

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

moveValue(

value: K,
toIndex?: undefined | number

)

#

Returns K

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 Optional

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

push(

value: K

)

#

Returns K

Adds an item to the end of the list.

pushAll(

values: Array

)

#

Returns void

Adds multiple items to the end of the list.

removeIndex(

index: number

)

#

Returns T

Removes a value at specific index.

removeValue(

value: T

)

#

Returns void

Removes all copies of an item from the list.

setAll(

newArray: Array

)

#

Returns void

Replaces all items in the list with newArray.

setIndex(

index: number,
value: T

)

#

Returns T

Replaces the value at index, which must already exist.

shift()

#

Returns Optional

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

swap(

a: number,
b: number

)

#

Returns void

Swaps two items in the list.

unshift(

value: K

)

#

Returns K

Adds an item as a first item in the list.

Events

Add event handlers to List object using its events.on() method.

Read about adding event handlers.

#clear

Param { oldValues: Array,
  type: "clear",
  target: this }

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

#insertIndex

Param { index: number,
  newValue: A,
  type: "insertIndex",
  target: this }

An item was inserted at index.

#moveIndex

Param { newIndex: number,
  oldIndex: number,
  value: A,
  type: "moveIndex",
  target: this }

An item was moved from oldIndex to newIndex.

#push

Param { newValue: A,
  type: "push",
  target: this }

An item was added to the end of the list.

#removeIndex

Param { index: number,
  oldValue: A,
  type: "removeIndex",
  target: this }

The item at index was removed.

#setIndex

Param { index: number,
  newValue: A,
  oldValue: A,
  type: "setIndex",
  target: this }

The item at index was replaced.

#swap

Param { a: A,
  b: A,
  type: "swap",
  target: this }

Two items swapped places.