Published
Edited
Jan 24, 2021
1 star
Insert cell
Insert cell
Insert cell
birthdataraw = FileAttachment("birthsraw.csv").csv()
Insert cell
Insert cell
Insert cell
Insert cell
birthdatatidied = FileAttachment("birthscore.csv").csv()
Insert cell
printTable(birthdatatidied.slice(0, 5))
Insert cell
Insert cell
birthdata1 = FileAttachment("birthdata@2.json").json()
Insert cell
printTable(birthdata1.slice(0, 5))
Insert cell
Insert cell
birthdatacondensed = FileAttachment("birthdatacondensed.json").json()
Insert cell
printTable(birthdatacondensed.slice(0, 5))
Insert cell
Insert cell
Insert cell
Insert cell
vl
.markBar()
.data(birthdata1) // Using the birth data
.encode(vl.x().field("Year"), vl.y().fieldQ("United_Kingdom"))
.render()
Insert cell
Insert cell
vl
.markLine()
.data(birthdata1) // Using the tidied json data
.encode(vl.x().field("Year"), vl.y().fieldQ("United_Kingdom"))
.render()
Insert cell
Insert cell
vl
.markPoint()
.data(birthdatatidied) // Using the csv data
.encode(vl.x().field("Year"), vl.y().fieldQ("United Kingdom"))
.render()
Insert cell
Insert cell
vl
.markBar()
.data(birthdatacondensed) // Using the condensed data
.encode(
vl.x().fieldT("Year"),
vl.y().fieldQ("Births"),
vl.column().fieldN("Country"),
vl.tooltip(["Year", "Births"])
)
.render()
Insert cell
Insert cell
vl
.markBar()
.data(birthdatacondensed) // Using the condensed data
.encode(
vl.x().fieldT("Year"),
vl.y().fieldQ("Births"),
vl.color().fieldN("Country"),
vl.tooltip(["Year", "Births"])
)
.render()
Insert cell
Insert cell
vl
.markPoint({ filled: true })
.data(birthdatacondensed)
.encode(
vl.x().fieldT('Year'),
vl.y().fieldQ('Births'),
vl.color().fieldN('Country')
)
.render()
Insert cell
md`
Trying out one more chart as an exploration of the data set.
`
Insert cell
vl
.markRect({ filled: false })
.data(birthdatacondensed)
.encode(
vl.x().fieldO('Country'),
vl.y().fieldQ('Births'),
vl.tooltip(["Year", "Births"])
)
.render()
Insert cell
Insert cell
import { vl } from "@vega/vega-lite-api"
Insert cell
import { printTable } from '@uwdata/data-utilities'
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