AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.6.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

class anychart.data.View Improve this Doc

Extends: anychart.core.Base

View is a representation of raw data.
Note: Default View is a view with default mapping.

Methods Overview

Miscellaneous
concat()Concatenates two views to make a derived view that contains rows from both views.
derive()Creates a derived view, containing just the same data set and order as this view does.
filter()Creates a derived view, containing only the rows that pass the filter.
find()Searches fieldName by fieldValue and returns it index (or the first match).
get()Gets the value from the row by row index and field name.
getIterator()Returns a new iterator for the current view.
getRowsCount()Returns the number of the rows in the current view.
meta()Getter for a metadata value. Learn how it works at anychart.data.Iterator#meta.
row()Gets a full row of the set by an index.
set()Sets the value to the row field by row index and field name.
sort()Creates a derived view that ensures sorting by a passed field.

Methods Description

concat

Concatenates two views to make a derived view that contains rows from both views.

Params:

NameTypeDescription
otherViewanychart.data.View | ArrayA view, data set or even an array to concat with.

Returns:

anychart.data.View - The new derived view.

derive

Creates a derived view, containing just the same data set and order as this view does.

Returns:

anychart.data.View - The new derived view.

filter

Creates a derived view, containing only the rows that pass the filter.

Params:

NameTypeDescription
fieldNamestringA field which value will be passed to a filter function.
funcfunctionA filter function that should accept a field value and return true if the row should be included into the resulting view.

Returns:

anychart.data.View - The new derived view.

find

Searches fieldName by fieldValue and returns it index (or the first match).

Params:

NameTypeDescription
fieldNamestringName of the field.
fieldValue*Value of the field.

Returns:

number - Index in view.

get

Gets the value from the row by row index and field name.

Params:

NameTypeDescription
rowIndexnumberIndex of the row to get field value from.
fieldNamestringThe name of the field to be fetched from the current row.

Returns:

* - The field value or undefined, if not found.

getIterator

Returns a new iterator for the current view.

Returns:

anychart.data.Iterator - New iterator.

getRowsCount

Returns the number of the rows in the current view.

Returns:

number - The number of the rows in the set.

meta

Getter for a metadata value. Learn how it works at anychart.data.Iterator#meta.

Params:

NameTypeDescription
indexnumberRow index.
namestringName of the metadata field.

Returns:

* - Current value.
Setter for a metadata value. Learn how it works at anychart.data.Iterator#meta.

Params:

NameTypeDescription
indexnumberRow index.
namestringName of the metadata field.
value*Value to set.

Returns:

anychart.data.View - Self instance for method chaining.

row

Gets a full row of the set by an index.

Params:

NameTypeDescription
rowIndexnumberAn index of the row to fetch.

Returns:

* - The row.
Example.
// Data
 [
   [1, 2, 4, 7],
   [11, 12, 14, 17],
   [21, 22, 24, 27]
 ]
 view.row(2); // returns [21, 22, 24, 27]
 view.row(3); // returns undefined
Sets a row of the set by an index.

Params:

NameTypeDescription
rowIndexnumberAn index of the row to fetch.
value*A value to set.

Returns:

* - Previous value of the row.
Example.
// Data
 [
   [1, 2, 4, 7],
   [11, 12, 14, 17],
   [21, 22, 24, 27]
 ]
 view.row(2, [2, 2, 2, 2]); // returns [21, 22, 24, 27]
 view.row(3, {'low': 4, 'high': 11}); // returns undefined

set

Sets the value to the row field by row index and field name.

Params:

NameTypeDescription
rowIndexnumber
fieldNamestring
value*

Returns:

anychart.data.View - Itself for chaining.

sort

Creates a derived view that ensures sorting by a passed field.

Params:

NameTypeDescription
fieldNamestringA field name to make sort by.
comparatorfunctionA sorting function that should accept two field values and return numeric result of the comparison.

Returns:

anychart.data.View - The new derived view.
Creates a derived view that ensures sorting by a passed field.

Params:

NameTypeDefaultDescription
fieldNamestring
A field name to make sort by.
orderanychart.enums.Sort
'asc'
String value of anychart.enums.Sort enumeration except NONE.

Returns:

anychart.data.View - The new derived view.