Collection of datasets used in Vega and Vega-Lite examples. This data lives at https://github.com/vega/vega-datasets and https://cdn.jsdelivr.net/npm/vega-datasets.
Common repository for example datasets used by Vega related projects. Keep changes to this repository minimal as other projects (Vega, Vega Editor, Vega-Lite, Polestar, Voyager) use this data in their tests and for examples.
The list of sources is in SOURCES.md.
To access the data in Observable, you can import vega-dataset
. Try our example notebook. To access these datasets from Python, you can use the Vega datasets python package. To access them from Julia, you can use the VegaDatasets.jl julia package.
These datasets are intended only for instructional and demonstration purposes. Datasets may contain intentional inconsistencies or errors to provide opportunities for data cleaning exercises and to illustrate common data quality issues.
We use semantic versioning. However, since this package serves datasets we have additional rules about how we version data.
We do not change data in patch releases except to resolve formatting issues. Minor releases may change the data but only update datasets in ways that do not change field names or file names. Minor releases may also add datasets. Major versions may change file names, file contents, and remove or update files.
You can also get the data directly via HTTP served by GitHub or jsDelivr (a fast CDN) like:
https://vega.github.io/vega-datasets/data/cars.json or with a fixed version (recommended) such as https://cdn.jsdelivr.net/npm/vega-datasets@2/data/cars.json.
You can find a full listing of the available datasets at https://cdn.jsdelivr.net/npm/vega-datasets/data/.
npm i vega-datasets
Now you have all the datasets in a folder in node_modules/vega-datasets/data/
.
npm i vega-datasets
Now you can import data = require('vega-datasets')
and access the URLs of any dataset with data[NAME].url
. data[NAME]()
returns a promise that resolves to the actual data fetched from the URL. We use d3-dsv to parse CSV files.
Here is a full example
import data from 'vega-datasets';
const cars = await data['cars.json']();
// equivalent to
// const cars = await (await fetch(data['cars.json'].url)).json();
console.log(cars);
Install dependencies with yarn
.
To make a release, run npm run release
.