Published
Edited
Jul 11, 2022
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data_list = raw_data.map(d => {
return [
d.geoid.slice(0,maxDigit), [
percent(+d.black_alone, +d.total),
percent(+d.latino_alone, +d.total)
]
];
});
Insert cell
aggregated_data = Array.from(d3.rollup(raw_data, v => ({
black_alone: d3.sum(v, d=> d.black_alone),
latino_alone: d3.sum(v, d=> d.latino_alone),
total: d3.sum(v, d=> d.total),
geoid: v[0].geoid.slice(0, maxDigit)
}),
d => d.geoid.slice(0, maxDigit)).values())
Insert cell
data = {
const data_list = aggregated_data.map(d => {
return [
d.geoid.slice(0,maxDigit), [
percent(+d.black_alone, +d.total),
percent(+d.latino_alone, +d.total)
]
];
});
const data_map = new Map(data_list);
return Object.assign(data_map, {title: ["Black", "Latino"]});
}
Insert cell
percent = (a,b) => ((a/b)*100).toFixed(1)
Insert cell
raw_data = await d3.csv("https://raw.githubusercontent.com/datadesk/census-data-downloader/4ade2a3feaf31843753b3a1fde38d4161dc58308/data/processed/acs5_2017_race_counties.csv")
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
import {slider} from "@jashkenas/inputs"
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