Public
Edited
Feb 12
Insert cell
Insert cell
md`# My first exercise is about just data`
Insert cell
d3 = require("d3@5")
Insert cell
topojson = require("topojson-client@3")
Insert cell
counties = FileAttachment("Projected_US_Counties.json").json()
Insert cell
counties_features = topojson.feature(counties, counties.objects.Projected_US_Counties)
Insert cell
csv_data = d3.csvParse(await FileAttachment("nhgis0003_ds258_2020_county@1.csv").text(),({Total, WhtAlone, GEOCODE}) => [+GEOCODE, 100*+WhtAlone/Total])
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
Race = Array.from(csv_data.values(), d => d[1])
Insert cell
//this is how you map the id column to the values. We will use this for joining with topojson later.
data = Object.assign(new Map(csv_data), {title: ["White", "White Pct"]})
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