Public
Edited
Mar 5, 2021
1 fork
Insert cell
Insert cell
Insert cell
censusTractsSvg = function(geoJsonFeaturesCollection) {
const height = 1.4 * width;
const projection = d3.geoMercator()
.fitSize([width, height], geoJsonFeaturesCollection);

const pathGenerator = d3.geoPath()
.projection(projection);
const svg = d3.create('svg')
.attr("viewBox", [0, 0, width, height]);

const g = svg.append('g')
.selectAll('path')
.data(geoJsonFeaturesCollection.features)
.enter()
.append('path')
.attr('d', pathGenerator)
.attr('fill', d => questionableTracts.has(d.properties.tractce10) ? 'red' : 'lightSkyBlue')
.append('title')
.text(d => {
const properties = d.properties;
const state = d3.format("02d")(properties.statefp10);
const county = d3.format("03d")(properties.countyfp10);
const tract = d3.format("04d")(properties.name10);
const suffix = d3.format("02d")(properties.tractce10.slice(-2));
return state + '-' + county + '-' + tract + '.' + suffix;
})
return svg.node();
}
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
censusQueryUrl = 'https://api.census.gov/data/2019/acs/acs5?get=NAME,B01003_001E&for=tract:*&in=state:17'
Insert cell
illinoisCensusTractData = d3.json(censusQueryUrl)
Insert cell
Insert cell
Insert cell
Insert cell
population('770602')
Insert cell
Insert cell
Insert cell
Insert cell
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