AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 8.1.0 version of this document. Switch to the 8.4.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.
loadGoogleSpreadsheet()Loads the Google Spreadsheets.
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.
parseText()Text parsing.
set()Return instance of class anychart.data.Set.
table()Creates and returns a new instance of a data table.
tree()Creates and returns a new instance of the data tree.

Typedefs Overview

anychart.data.DataSettingsType definition for table data.
anychart.data.TextParsingSettingsSettings for parsing text.

Classes Overview

anychart.data.Iteratoranychart.data.Iterator class is used to work with data in a View.
anychart.data.MappingThe special view which allows mapping 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 fewer 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.TreeViewTreeView. Class of mapped tree.
anychart.data.TreeView.DataItemMapped data item class.
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:

NameTypeDescription
dataSetanychart.data.SetData set
fromIndexnumber"From" index
toIndexnumber"To" index
namesArray.<string>Field names
keysArray.<string>Keys

Returns:

anychart.data.Mapping - Returns an object mapping.

loadCsvFile

Loads the CSV file.

Params:

NameTypeDescription
urlstringURL of an CSV file or a script
onSuccessfunctionThe function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunctionFunction that is called if loading fails. Takes an error code as first argument and exception object or error message as the second argument.
methodstringSend method
contentArrayBuffer | ArrayBufferView | Blob | Document | FormData | stringData
headersObjectHeaders to add to the request
timeoutIntervalnumberNumber of milliseconds after which an incomplete request is aborted
withCredentialsbooleanWhether to send credentials with the request
context*Context for handler function

loadGoogleSpreadsheet

Loads the Google Spreadsheets. Learn more about loading Google Spreadsheet

Params:

NameTypeDescription
keystring | ObjectGoogle Spreadsheet key.
onSuccessfunctionThe function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunctionThe function that is launched if chart loading fails.
timeoutIntervalnumberNumber of milliseconds after which an incomplete request is aborted.
context*Context for handler function.

loadJsonFile

Loads the JSON file.

Params:

NameTypeDescription
urlstringURL of a JSON file or a script.
onSuccessfunctionThe function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunctionFunction that is called if loading fails. Takes an error code as first argument and exception object or error message as the second argument.
methodstringSend method
contentArrayBuffer | ArrayBufferView | Blob | Document | FormData | stringData.
headersObjectHeaders to add to the request
timeoutIntervalnumberNumber of milliseconds after which an incomplete request is aborted
withCredentialsbooleanWhether to send credentials with the request
context*Context for handler function

loadXmlFile

Loads the XML file.

Params:

NameTypeDescription
urlstringURL of an XML file or a script
onSuccessfunctionThe function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunctionFunction that is called if loading fails. Takes an error code as first argument and exception object or error message as the second argument.
methodstringSend method
contentArrayBuffer | ArrayBufferView | Blob | Document | FormData | stringData
headersObjectHeaders to add to the request
timeoutIntervalnumberNumber of milliseconds after which an incomplete request is aborted.
withCredentialsbooleanWhether to send credentials with the request
context*Context for handler function

mapAsTable

Maps passed data as an array of mappings.

Params:

NameTypeDescription
dataArray.<Array.<*>>Source data table.
modeanychart.enums.MapAsTableMode | stringMapping mode.
seriesCountnumberExplicit 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:

NameTypeDescription
tableSelectorstringCSS table selector
rowsSelectorstringRows selector in the CSS table
cellsSelectorstringCells selector in the CSS table
headersSelectorstringHeader selector in the CSS table
captionSelectorstringCaption selector in the CSS table
valueProcessorfunctionFunction that converts values from a table

Returns:

anychart.data.DataSettings - Returns data settings.

parseText

Text parsing.

Params:

NameTypeDescription
textstringText to parsing.
settingsanychart.enums.TextParsingMode | string | anychart.data.TextParsingSettingsParsing settings.

Returns:

Array.<Array.<(string|number)>> - Array of arrays.

set

Return instance of class anychart.data.Set.

Params:

NameTypeDescription
dataArray | stringData set raw data can be set here.
csvSettingsanychart.enums.TextParsingMode | string | anychart.data.TextParsingSettingsIf CSV string is passed, you can pass CSV parser settings here as a hash map.

Returns:

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

table

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

Params:

NameTypeDescription
keyColumnIndexnumberIndex of the column in with the table key field.
dateTimePatternstringKey column parsing pattern.
timeOffsetnumberShifts all input dates timeOffset hours forward. Defaults to zero.
baseDatenumber | DateBase date for the key column.
localestring | anychart.format.LocaleLocale to be used.

Returns:

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

tree

Creates and returns a new instance of the data tree.

Params:

NameTypeDescription
dataArray.<Object>Raw data.
fillMethodanychart.enums.TreeFillingMethod | stringFill method.

Returns:

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