DataLoader

Type class

Data Loader is responsible for loading and parsing external data.

There is just one instance of DataLoader per system. Unless you have a speicific reason, do not instantiate additional instances.

The global instance of Data Loader is accessible via:

am4core.dataLoader;
am4core.dataLoader;

A loading of specific data source is done via DataSource.

Please refer to DataSource for information how to use it.

IDataLoaderAdapters for a list of available Adapters

Sources

DataLoader can be used (imported) via one of the following packages.

/**
 * --------------------------------------------------------
 * Import from: "core.ts"
 * Use like: am4core.DataLoader
 * --------------------------------------------------------
 */
import * as am4core from "@amcharts/amcharts4/core";

/**
 * --------------------------------------------------------
 * Include via: <script src="core.js"></script>
 * Access items like: am4.DataLoader
 * --------------------------------------------------------
 */

Inheritance

DataLoader does not extend any other symbol.

DataLoader is not extended by any other symbol.

Properties

adapter
#

Type Adapter < DataLoader, IDataLoaderAdapters >

Default new Adapter<DataLoader,
IDataLoaderAdapters>(this)

Adapter.

Methods

getParserByData(

data: string,
contentType?: string

)

#

Returns DataParser

Tries to determine a parser out of content type and/or actual data.

getParserByType(

contentType: string

)

#

Returns DataParser

Instantiates a DataParser object based on the data type.

Built-in parser types are as follows:

  • "csv" or "text/csv"
  • "json" or "application/json"

load(

source: DataSource | DataSource[]

)

#

Returns void

Loads a supplied DataSource or an array of data sources, then calls their respective parse methods.

Events

DataLoader does not have any events.

Adapters

#getParserByData

Param { data: string,
  parser: DataParser,
  type: string }

Applied after the Data Loader determines suitable parser type based on its data examination.

#getParserByType

Param { parser: DataParser,
  type: string }

Applied after the Data Loader determines suitable parser type by data source's URL extension.