Published
Edited
May 27, 2020
Insert cell
md`# Distribution of Higher Education Institutions that Offer Degree Programs across China Mainland`
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
$schema= "https://vega.github.io/schema/vega-lite/v4.json"
Insert cell
d3 = require("d3-dsv@1")
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
countrie_url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/china/china-provinces-simplified.json"
Insert cell
vl.markGeoshape()
.data(vl.topojson(countrie_url).feature("CHN_adm1"))
.render()
Insert cell
vl.markGeoshape({fill: "white", stroke: "grey"})
.data(vl.topojson(countrie_url).feature("CHN_adm1"))
.width(1000)
.height(1000)
.render()
Insert cell
cities_file = FileAttachment("China cities@15.csv")
Insert cell
cities_text = cities_file.text()
Insert cell
cities_data = d3.csvParse(cities_text, d3.autoType)
Insert cell
printTable(cities_data.slice(0, 31))
Insert cell

{const map = vl.markGeoshape({fill: "white", stroke: "grey"})
.data(vl.topojson(countrie_url).feature("CHN_adm1"))
const city_points = vl.markPoint({filled: true, opacity: 0.5})
.data(cities_data)
.transform(vl.filter("datum.heis >= 3"))
.encode(vl.latitude().fieldQ("lat"),
vl.longitude().fieldQ("lng"),
vl.color().value("darkred"),
vl.size().fieldQ("heis").scale({range:[0, 3000]}),
vl.tooltip("city"))
return vl.layer(map, city_points)
.width(800)
.height(800)
.render()

}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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