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

namespace anychart.data Improve this Doc

Classes for handling data structures/sources
The following data types/hierarchy is supported:

You can map any of these data sets to (anychart.data.View), and then work with it using anychart.data.Iterator iterator.

Functions Overview

buildMapping()Creates data mapping.
loadCsvFile()Loads the CSV file.
loadJsonFile()Loads the JSON file.
loadXmlFile()Loads the XML file.
mapAsTable()Maps passed data as an array of mappings.
parseHtmlTable()Parses HTML table to table data.
set()Return instance of class anychart.data.Set.
table()Creates and returns new instance of data table.
tree()Creates and returns new instance of data tree.

Typedefs Overview

anychart.data.TableDataType definition for table data.

Classes Overview

anychart.data.Iteratoranychart.data.Iterator class is used to work with data in a View.
anychart.data.MappingSpecial view which allows to map anychart.data.Set storages.
anychart.data.SetLinear data storage.
anychart.data.TableStock data table constructor.
anychart.data.TableComputerStock table computer constructor.
anychart.data.TableComputer.RowProxyRow proxy for computational functions.
anychart.data.TableIteratorTable iterator class. Assumes iterator (if any) to return not less keys than the table has.
anychart.data.TableMappingTable mapping constructor.
anychart.data.TableSelectableTable mapping proxy that supports selection
anychart.data.TableSelectable.RowProxyRepresents table row with associated mapping. Allows fetching rows values.
anychart.data.TraverserTree data traverser.
anychart.data.TreeTree data model.
anychart.data.Tree.DataItemTree data item.
anychart.data.ViewView is a representation of raw data.

Functions Description

buildMapping

Creates data mapping.
Creates object mapping if keys are set, otherwise - array mapping.

Params:

Name Type Description
dataSet anychart.data.Set Data set
fromIndex number "From" index
toIndex number "To" index
names Array.<string> Field names
keys Array.<string> Keys

Returns:

anychart.data.Mapping - Returns an object mapping.

Try it:

loadCsvFile

Loads the CSV file.

Params:

Name Type Description
url string URL of an CSV file or a script
onSuccess function The function that is launched after chart is successfully loaded
onError function The function that is launched if chart loading fails
method string Send method
content ArrayBuffer | ArrayBufferView | Blob | Document | FormData | string Data
headers Object Headers to add to the request
timeoutInterval number Number of milliseconds after which an incomplete request will be aborted
withCredentials boolean Whether to send credentials with the request
context * Context for handler function

Try it:

loadJsonFile

Loads the JSON file.

Params:

Name Type Description
url string URL of a JSON file or a script
onSuccess function The function that is launched after chart is successfully loaded
onError function The function that will be loaded in case loading chart error
method string Send method
content ArrayBuffer | ArrayBufferView | Blob | Document | FormData | string Data
headers Object Headers to add to the request
timeoutInterval number Number of milliseconds after which an incomplete request will be aborted
withCredentials boolean Whether to send credentials with the request
context * Context for handler function

Try it:

loadXmlFile

Loads the XML file.

Params:

Name Type Description
url string URL of an XML file or a script
onSuccess function The function that is launched after chart is successfully loaded
onError function The function that is launched if chart loading fails
method string Send method
content ArrayBuffer | ArrayBufferView | Blob | Document | FormData | string Data
headers Object Headers to add to the request
timeoutInterval number Number of milliseconds after which an incomplete request will be aborted
withCredentials boolean Whether to send credentials with the request
context * Context for handler function

Try it:

mapAsTable

Maps passed data as an array of mappings.

Params:

Name Type Description
data Array.<Array.<*>> Source data table.
mode anychart.enums.MapAsTableMode | string Mapping mode.
seriesCount number Explicit number of series to make mapping for. If not set, auto-determination by the first table row is used.

Returns:

Array.<anychart.data.Mapping> - Returns an array of mappings, one per series.

parseHtmlTable

Parses HTML table to table data.

Params:

Name Type Description
tableSelector string CSS table selector
rowsSelector string Rows selector in the CSS table
cellsSelector string Cells selector in the CSS table
headersSelector string Header selector in the CSS table
captionSelector string Caption selector in the CSS table
valueProcessor function Function that converts values from a table

Returns:

anychart.data.TableData - Returns an object with the table data.

Try it:

set

Return instance of class anychart.data.Set.

Params:

Name Type Description
data Array | string Data set raw data can be set here.
csvSettings Object.<string, (string|boolean)> If CSV string is passed, you can pass CSV parser settings here as a hash map.

Returns:

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

Try it:

table

Creates and returns new instance of data table. Key column index defaults to zero column.

Params:

Name Type Description
keyColumnIndex number Index of the column in which table index is located.

Returns:

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

Try it:

tree

Creates and returns new instance of data tree.

Params:

Name Type Description
data Array.<Object> Raw data.
fillMethod anychart.enums.TreeFillingMethod Fill method.

Returns:

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

Try it: