Top
You are looking at an outdated 7.3.0 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.data.Traverser Improve this Doc

Tree data traverser.

Methods Overview

Miscellaneous
advance()Advances traverser to the next item.
current()Gets current tree data item.
get()Gets current data item's data value by field specified.
getDepth()Gets depth of current data item.
meta()Gets/sets a meta value.
nodeYieldCondition()Sets function that decides if data item must be returned while passage.
reset()Resets traverser.
set()Sets current item's value by key specified.
toArray()Turns current traverser to an array of tree data items.
traverseChildrenCondition()Sets function that decides if we go through data item's children while passage.

Methods Description

advance

Advances traverser to the next item.

Returns:

boolean - - Returns True if moved to the next item, otherwise returns False.

current

Gets current tree data item.

Returns:

anychart.data.Tree.DataItem undefined -

get

Gets current data item's data value by field specified.

Params:

Name Type Description
key string Key of value to be got from current data item.

Returns:

* - - Value.

getDepth

Gets depth of current data item.

Returns:

number - - Depth.

meta

Gets/sets a meta value.

Params:

Name Type Description
key string Key.
value * Optional value.

Returns:

* - - Value or itself for method chaining if method is used as setter.

nodeYieldCondition

Sets function that decides if data item must be returned while passage. Note: if passed argument is passed by not a function, value will be reset to default value that always returns 'true'.

Params:

Name Type Description
value function Function to be set.

Returns:

function anychart.data.Traverser - - Current decider function or itself for method chaining.

reset

Resets traverser.

Returns:

anychart.data.Traverser - - Itself for method chaining.

set

Sets current item's value by key specified.

Params:

Name Type Description
key string Key.
value * Value.

Returns:

anychart.data.Traverser - - Itself for method chaining.

toArray

Turns current traverser to an array of tree data items. NOTE: This method resets a traverser state before turning to array and after it (be very careful in this method usage while advance()-passage). Also don't forget to reset traverser after this method usage.

Returns:

Array.<anychart.data.Tree.DataItem> - - Resulting array.

traverseChildrenCondition

Sets function that decides if we go through data item's children while passage. Note: if passed argument is passed by not a function, value will be reset to default value that always returns 'true'.

Params:

Name Type Description
value function Function to be set.

Returns:

function anychart.data.Traverser - - Current decider function or itself for method chaining.