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

class anychart.data.View Improve this Doc

Extends: anychart.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.
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.
row()Gets a full row of the set by an index.
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:

Name Type Description
otherView anychart.data.IView | Array A view, data set or even an array to concat with.

Returns:

anychart.data.IView - 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.

Try it:

filter

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

Params:

Name Type Description
fieldName string A field which value will be passed to a filter function.
func function A 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.

getIterator

Returns a new iterator for the current view.

Returns:

anychart.data.Iterator - New iterator.

Try it:

getRowsCount

Returns the number of the rows in the current view.

Returns:

number - The number of the rows in the set.

Try it:

meta

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

Params:

Name Type Description
index number Row index.
name string Name of the metadata field.

Returns:

* - Current value.

Try it:

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

Params:

Name Type Description
index number Row index.
name string Name of the metadata field.
value * Value to set.

Returns:

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

Try it:

row

Gets a full row of the set by an index.
Note: If there is no row with the given index, methods returns undefined.
See sample at anychart.data.Set#row

Params:

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

Returns:

* - The row.

Try it:

Sets a row of the set by an index.
Note: Previous value of a row is returned but it is lost completely after that!.

Params:

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

Returns:

* - Previous value of the row.

sort

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

Params:

Name Type Description
fieldName string A field name to make sort by.
comparatorOrOrder anychart.enums.Sort | function A sorting function that should accept two field values and return numeric result of the comparison or string value of anychart.enums.Sort enumeration except NONE. Defaults to anychart.enums.Sort.ASC.

Returns:

anychart.data.View - The new derived view.