Published
Edited
Dec 4, 2020
Importers
1 star
Insert cell
Insert cell
stateFiles = [
FileAttachment("district-of-columbia@2.json"),
FileAttachment("hawaii@2.json"),
FileAttachment("delaware@2.json"),
FileAttachment("maryland@2.json"),
FileAttachment("alaska@2.json"),
FileAttachment("wyoming@2.json"),
FileAttachment("new-jersey@2.json"),
FileAttachment("nevada@4.json"),
FileAttachment("arizona@4.json"),
FileAttachment("rhode-island@2.json"),
FileAttachment("idaho@2.json"),
FileAttachment("north-dakota@2.json"),
FileAttachment("new-mexico@2.json"),
FileAttachment("oregon@2.json"),
FileAttachment("mississippi@2.json"),
FileAttachment("south-dakota@2.json"),
FileAttachment("alabama@2.json"),
FileAttachment("wisconsin@2.json"),
FileAttachment("utah@2.json"),
FileAttachment("nebraska@2.json"),
FileAttachment("virginia@2.json"),
FileAttachment("south-carolina@2.json"),
FileAttachment("west-virginia@2.json"),
FileAttachment("tennessee@2.json"),
FileAttachment("arkansas@2.json"),
FileAttachment("oklahoma@2.json"),
FileAttachment("indiana@2.json"),
FileAttachment("iowa@2.json"),
FileAttachment("connecticut@2.json"),
FileAttachment("kansas@2.json"),
FileAttachment("louisiana@2.json"),
FileAttachment("ohio@2.json"),
FileAttachment("montana@2.json"),
FileAttachment("kentucky@2.json"),
FileAttachment("minnesota@2.json"),
FileAttachment("washington@2.json"),
FileAttachment("michigan@2.json"),
FileAttachment("florida@2.json"),
FileAttachment("colorado@2.json"),
FileAttachment("new-york@2.json"),
FileAttachment("pennsylvania@4.json"),
FileAttachment("illinois@2.json"),
FileAttachment("missouri@2.json"),
FileAttachment("california@2.json"),
FileAttachment("vermont@2.json"),
FileAttachment("maine@2.json"),
FileAttachment("new-hampshire@2.json"),
FileAttachment("massachusetts@2.json"),
FileAttachment("north-carolina@2.json"),
FileAttachment("georgia@4.json"),
FileAttachment("texas@2.json")
]
Insert cell
state = new Map(
(await Promise.all(
stateFiles.map(async file => await file.json())
)).map(d => [d.data.races[0].state_id, d])
)
Insert cell
Insert cell
president = FileAttachment("president@3.json").json()
Insert cell
presidentByState = new Map(president.data.races.map(d => [d.state_id, d]))
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