AnyChart
API Reference
Still have questions?
Contact support
Top

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
onSuccessfunction(data:Array.<string>)The function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunction(errorCode:number, exceptionOrMessage:Object|string)Function 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.
onSuccessfunction(data:anychart.data.DataSettings, settings:Object)The 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.
onSuccessfunction(data:Array.<(Object|string|number|boolean|null)>)The function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunction(errorCode:number, errorMessage:string)Function 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
onSuccessfunction(data:Object)The function that is launched after chart is successfully loaded. Takes resulting data object parsed from response string as an argument.
onErrorfunction(errorCode:number, exceptionOrMessage:Object|string)Function 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 | stringDataset 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
keyColumnIndexnumber | stringIndex of the column in with the table key field or field name in the array.
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> | stringRaw data or CSV-string. If the string is passed, the second parameter is interpreted as fields mapping.
fillMethodOrCsvMappinganychart.enums.TreeFillingMethod | ObjectFill method or CSV mapping object. This parameter is interpreted as mapping object if the first parameter is a string. Mapping object should have the structure like
   //'nameOfField': index_of_column
   mapping = {
     'id': 0,
     'name': 1,
     'value': 15
   };
 
csvSettingsanychart.enums.TextParsingMode | string | anychart.data.TextParsingSettingsCSV settings object. Should be fields like
rowsSeparator - string or undefined, if it is undefined, it will not be set.
columnsSeparator - string or undefined, if it is undefined, it will not be set.
ignoreTrailingSpaces - boolean or undefined, if it is undefined, it will not be set.
ignoreFirstRow - boolean or undefined, if it is undefined, it will not be set.
fieldsMappingObjectField mapping object. Maps only first-level data.

Returns:

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