-
Notifications
You must be signed in to change notification settings - Fork 42
Data
Wiki ▸ API Reference ▸ Data
Polychart.js creates a wrapper around each data set using the polyjs.data function. Data sets can be in CSV or JSON format, and can be retrieved from an AJAX endpoint. When using polyjs.data() the data format will be guessed. When using the other functions the format is provided by the developer.
Returns a Polychart.js data object. The parameter blob can be a data object in JSON, CSV, or it can be a URL, or it can be an
object with the following attributes:
-
data- the data object in JSON, CSV or URL -
meta- the metadata object (see section below)
Returns a Polychart.js data object from a JSON data source. The data can be formatted in one of three ways:
- An array of objects (this is the way Polychart represents objects internally), with each object
containing attribute keys corresponding to column headers, and values for each column header.
[ {a: 'val1', b: 23, c: '2012/12/20'}, {a: 'val2', b: 24, c: '2012/12/21'}, ... ] - An object (key-value pair) with keys corresponding to column headers, mapping to an array of values. `{a: ['val1', 'val2', ...], b: [23, 24, ...], c: ['2012/12/20', '2012/12/21']}
- An array of arrays. Each inner array correspond to one row of data.
Note that if this option is used, then the metadata should be passed in.
[ ['val1', 23, '2012/12/20'], ['val2', 24, '2012/12/21'], ...]
Returns a Polychart.js data object from a CSV data source. The data object should be a string of CSV format.
Returns a Polychart.js data object that retrieves data from an AJAX endpoint. The AJAX endpoint should return data
in one of the formats accepted by polyjs.data (other than the url format).
The meta object can either be an array representing the column headers, or an object where the keys correspond to the
column headers, and the values are objects with the following attributes:
-
type- either "date", "num" or "cat" depending on the types of data (datetime, numeric, or categorical/string). -
format- the date format for datetime data (in moment.js data format)
Meta data definitions are helpful when Polychart.js is not parsing your data correctly (e.g. parsing categorical values as dates, or dates as numerics, etc).