Published
Edited
Feb 3, 2020
1 fork
10 stars
Insert cell
md`# Introduction to Programming`
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
lecture_file_uk = FileAttachment("lecture_data_uk.csv")
Insert cell
lecture_file = FileAttachment("lecture_data.csv")
Insert cell
lecture_text_uk = lecture_file_uk.text()
Insert cell
lecture_text = lecture_file.text()
Insert cell
d3 = require("d3-dsv@1")
Insert cell
lecture_data_uk = d3.csvParse(lecture_text_uk, d3.autoType)
Insert cell
lecture_data = d3.csvParse(lecture_text, d3.autoType)
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
printTable(lecture_data.slice(0, 10))
Insert cell
vl.markArea()
.data(lecture_data_uk)
.encode(vl.x().fieldN("Year"),
vl.y().fieldQ("GDP per capita"))
.render()
Insert cell
vl.markPoint({filled: true})
.data(lecture_data)
.encode(vl.y().fieldQ("Life Expectancy").scale({domain:[50, 90]}),
vl.x().fieldQ("GDP per capita").scale({type:"log"}),
vl.size().fieldQ("Population").scale({range: [50, 1000]}),
vl.tooltip("Country Name"),
vl.opacity().value(0.4))
.height(700)
.width(700)
.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