Published
Edited
Oct 12, 2022
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
w = d3.min([width, 1000])
Insert cell
population_map = new Map(population.map((o) => [o.abbr, o.pop]))
Insert cell
population = {
let population = d3.sort(
await FileAttachment("pop.csv").csv(),
(o) => o.name
);
population.forEach(function (o) {
o.pop = parseInt(o.pop);
o.abbr = abbreviation_map.get(o.fips);
});
let code48 = Array.from(abbreviation_map.values());
population = population.filter((o) => code48.indexOf(o.abbr) > -1);
population.max = d3.max(population.map((o) => o.pop));

return population;
}

// Comes from this Cenus API call:
// (
// await (
// await fetch(
// "https://api.census.gov/data/2018/acs/acs5?get=NAME,B02001_001E&for=state"
// )
// ).json()
// ).slice(1)
Insert cell
abbreviation_map = new Map([
["01", "AL"],
["04", "AZ"],
["05", "AR"],
["06", "CA"],
["08", "CO"],
["09", "CT"],
["10", "DE"],
["12", "FL"],
["13", "GA"],
["16", "ID"],
["17", "IL"],
["18", "IN"],
["19", "IA"],
["20", "KS"],
["21", "KY"],
["22", "LA"],
["23", "ME"],
["24", "MD"],
["25", "MA"],
["26", "MI"],
["27", "MN"],
["28", "MS"],
["29", "MO"],
["30", "MT"],
["31", "NE"],
["32", "NV"],
["33", "NH"],
["34", "NJ"],
["35", "NM"],
["36", "NY"],
["37", "NC"],
["38", "ND"],
["39", "OH"],
["40", "OK"],
["41", "OR"],
["42", "PA"],
["44", "RI"],
["45", "SC"],
["46", "SD"],
["47", "TN"],
["48", "TX"],
["49", "UT"],
["50", "VT"],
["51", "VA"],
["53", "WA"],
["54", "WV"],
["55", "WI"],
["56", "WY"]
])
Insert cell
tippy_style = html`<div style="display: none; height: 0px"><link rel="stylesheet" href="${await require.resolve(
`tippy.js/themes/light-border.css`
)}"></div>`
Insert cell
tippy = require("tippy.js@6")
Insert cell
require.resolve(`tippy.js/themes/light-border.css`)
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