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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more