Published
Edited
Jul 13, 2021
Insert cell
Insert cell
Insert cell
Insert cell
// d3 comes with built in projections check out the list => https://github.com/d3/d3-geo
myProjection = d3.geoAlbersUsa();
Insert cell
Insert cell
geoPathGenerator = d3.geoPath().projection(myProjection)
Insert cell
Insert cell
{
const svg = d3.create('svg')
.attr('width', 900)
.attr('height', 530);
// append g to svg
svg.append('g')
.selectAll('path')
.data(statesGeoJson.features)
.enter()
.append('path')
.attr('d', geoPathGenerator)
.attr('fill', 'lightblue')
return svg.node()
}
Insert cell
Insert cell
statesGeoJson = FileAttachment("statesGeoJson.json").json()
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