Published
Edited
Feb 24, 2021
17 stars
Insert cell
Insert cell
Insert cell
md`This means that everything in this document is actually some kind of code, which you can edit. See below!`
Insert cell
Insert cell
Insert cell
a = 5
Insert cell
addTwo = x => x+2
Insert cell
addTwo(a)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = (await require('vega-datasets'))['gapminder.json']()
Insert cell
Insert cell
md`${data.length} rows, ${Object.keys(data[0]).length} columns! (This is a live data value by the way, see below)`
Insert cell
Insert cell
printTable(data.slice(0, 10))
Insert cell
Insert cell
Insert cell
data2000 = data.filter(d => d.year === 2000)
Insert cell
printTable(data2000.slice(0, 10))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
vl.markPoint()
.data(data2000)
.render()
Insert cell
Insert cell
vl.markPoint()
.data(data2000)
.encode(
vl.x().field('fertility')
)
.render()
Insert cell
Insert cell
Insert cell
vl.markPoint()
.data(data2000)
.encode(
vl.x().fieldQ('fertility')
)
.render()
Insert cell
Insert cell
vl.markPoint()
.data(data2000)
.encode(
vl.x().fieldQ('fertility'),
vl.y().fieldN('cluster')
)
.render()

// Comment: What happens if we do not annotate "cluster" as nominal data? Or if nothing happens, why might that be?
Insert cell
Insert cell
Insert cell
// Add your code here to produce the visualization above
Insert cell
Insert cell
vl.markBar()
.data(data2000)
.encode(
vl.x().fieldN('cluster'),
vl.y().count()
)
.render()
Insert cell
Insert cell
vl.markBar()
.data(data2000)
.encode(
vl.x().fieldQ('life_expect').bin(true),
vl.y().count()
)
.render()
Insert cell
Insert cell
Insert cell
Insert cell
// Code for Visualization 1:

Insert cell
// Code for Visualization 2:

Insert cell
// Code for Visualization 3:

Insert cell
Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
// Code to recreate the above visualization:

Insert cell
Insert cell
Insert cell
Insert cell
// Code for bi-variate visualization 1:

Insert cell
// Code for bi-variate visualization 2:

Insert cell
// Code for bi-variate visualization 3:


Insert cell
Insert cell
Insert cell
// Code to recreate the visualization above:

Insert cell
Insert cell
Insert cell
// Code to recreate the visualization above:

Insert cell
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