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

class anychart.data.Set Improve this Doc

Extends: anychart.Base

Linear data storage.
Data is stored as an array or rows where each row contains several columns (see Listing 1 below). To start working with this storage you need to map columns using anychart.data.Set#mapAs method (you can create as many mappings as you like).
Each field can be a number, a string, a function, an array or an object. Data fields can of any type and they way you read them depends on mapping only: anychart.data.Set#mapAs. Sample mappings are shown in code samples 3, 4 and 5.

Methods Overview

Miscellaneous
data()Getter for the data in the Set.
getRowsCount()Returns the number of the rows in the current data set.
mapAs()Defines data mapping.
row()Gets the full row of the set by the index.

Methods Description

data

Getter for the data in the Set.

Returns:

Array - Data array of the Set.
Setter for Set data.

Params:

Name Type Description
value Array A value to set.

Returns:

anychart.data.Set - The instance of anychart.data.Set class for method chaining.

Try it:

getRowsCount

Returns the number of the rows in the current data set.

Returns:

number - The number of the rows in the set.

mapAs

Defines data mapping.
You can define mappings for the different types of data (see samples). Default mapping is shown in anychart.data.Set constructor samples.

Params:

Name Type Default Description
arrayMapping Object.<Array.<number>>
{
  'x': [0],
  'value': [1, 0],
  'size': [2],
  'open': [1],
  'high': [2],
  'low': [3, 1],
  'close': [4]
}
Column mapping for the rows which are arrays.
objectMapping Object.<Array.<string>>
{'value': ['value', 'y', 'close']}
Column mapping for the rows which are objects.
defaultProps Array.<string>
['value', 'close']
The names of the fields to map to if a row is a string, number or a function. Does not work in cases when a row is an object.
indexProps Array.<string>
['x']
The names of the fields to be mapped to the current index if other options failed.

Returns:

anychart.data.Mapping - The mapping for the data set.

Try it:

row

Gets the full row of the set by the index.
Note: If there is no row for the index - returns undefined.

Params:

Name Type Description
rowIndex number The index of the row to fetch.

Returns:

* - The current row.

Try it:

Sets the row in the set by the index.
Note: Replaces the current value, previous values is returned but it is lost completely after that!

Params:

Name Type Description
rowIndex number The index of the row to fetch.
value * The value to set.

Returns:

* - The previous value of the row.

Try it: