Data
Akin to Vega’s data model, the basic data model used by Vega-Lite is tabular data, similar to a spreadsheet or a database table. Individual data sets are assumed to contain a collection of records, which may contain any number of named data fields.
{
"data": ... , // data
"mark": ... ,
"encoding": ... ,
...
}
Vega-Lite’s optional top-level data
property describes the visualization’s data source as part of the specification, which can be either inline data (values
) or a URL from which to load the data (url
). Alternatively, if the data
property is not specified, the data source can be bound at runtime.
Here is a list of all properties describing data
source:
Property | Type | Description |
---|---|---|
values | Array | Array of object that maps field names to their values. |
url | String | A URL from which to load the data set. Use the formatType property to ensure the loaded data is correctly parsed. |
formatType | String | Type of input data: "json" , "csv" , "tsv" . The default format type is determined by the extension of the file url. If no extension is detected, "json" will be used by default. |
Inline Data
Inline Data can be specified using values
property.
For example, the following specification embeds an inline data table with two rows and two columns (a
and b
).
Data from URL
Data can be specified from url using the url
property. In addition, format of the input data can be optionally specified using formatType
property.
For example, the following specification loads data from a relative url
: data/cars.json
. Note that the format type is implicitly json by default.