Published
Edited
Mar 3, 2021
1 fork
1 star
Insert cell
md`# Choropleth Map of China`
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
Insert cell
Insert cell
Insert cell
Insert cell
// viewof height = slider({min: "150", max: 700, step:10, title: "height:"})
height = 600
Insert cell
md`## Utils`
Insert cell
// projection = d3.geoTransverseMercator().rotate([-110,0]).fitExtent([[65, 80], [width, height]], china_p);

// projection = d3.geoAzimuthalEqualArea()
// .rotate([-110, -40])
// .scale(height)

projection = d3.geoMercator()
.center([110, 40])
.scale([height]);
Insert cell
path = d3.geoPath(projection)
Insert cell
Insert cell
data = Object.assign(new Map(d3.csvParse(await FileAttachment("total@3.csv").text(), ({place, total}) => [place, +total])))
Insert cell
census_data = d3.csvParse(await FileAttachment("total@3.csv").text()).filter(d => d.place!=="全国")
Insert cell
china_p = topojson.feature(china_geo, china_geo.objects.China_adm)
Insert cell
Insert cell
md`## Library`
Insert cell
topojson = require("topojson-client@3")
Insert cell
d3 = require("d3@6", "d3-geo-projection@2")
Insert cell
import {legend} from "@mydu/color-legend"
Insert cell
import {slider, radio, text, select, color} from '@jashkenas/inputs'
Insert cell
scaleCluster = require("d3-scale-cluster")
Insert cell
md`## Reference
https://observablehq.com/@neocartocnrs/cheat-sheet-topojson
https://observablehq.com/@d3/color-legend
https://observablehq.com/@d3/quantile-quantize-and-threshold-scales
`
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