Published
Edited
Feb 16, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
Insert cell
data = require('vega-datasets') // import vega_datasets
Insert cell
cars = data['cars.json']() // load and parse cars data
Insert cell
printTable(cars.splice(0,5)) // display the first five rows
Insert cell
Insert cell
data['cars.json'].url
Insert cell
Insert cell
md`# Basic Bar Chart`
Insert cell
vl.markBar()
.data(cars)
.encode(
vl.x().average('Miles_per_Gallon'),
vl.y().fieldN('Origin')
)
.render()
Insert cell
Insert cell
vl.markPoint().data(cars).encode(
vl.x().fieldQ('Horsepower'),
vl.y().fieldQ('Miles_per_Gallon'),
vl.color().fieldN('Origin'),
vl.tooltip(['Name', 'Origin', 'Year']) // show the Name and Origin fields in a tooltip
).render()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more