Public
Edited
Sep 21, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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
uspopulation = totals.reduce((a, b) => a + b.population, 0);
Insert cell
uscases = totals.reduce((a, b) => a + (b.cases ? parseInt(b.cases) : 0), 0)
Insert cell
uscaserate = uscases / uspopulation
Insert cell
usdeaths = totals.reduce((a, b) => a + (b.deaths ? parseInt(b.deaths) : 0), 0)
Insert cell
usdeathrate = usdeaths / uspopulation
Insert cell
maxCaseRateDelta = d3.max(perCapitaTotals, (d) => d.caseRateDelta)
Insert cell
maxDeathRateDelta = d3.max(perCapitaTotals, (d) => d.deathRateDelta)
Insert cell
maxCaseRate = d3.max(perCapitaTotals, (d) => d.caseRate)
Insert cell
minCaseRate = d3.min(perCapitaTotals, (d) => d.caseRate)

Insert cell
noCases = perCapitaTotals.filter((d) => d.cases == undefined)
Insert cell
maxDeathRate = d3.max(perCapitaTotals, (d) => d.deathRate)
Insert cell
Insert cell
minCaseRateDelta = d3.min(perCapitaTotals, (d) => d.caseRateDelta)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
shapesWithPopulations.filter((d) => nycFips.includes(d.id))
Insert cell
shapesWithPopulations.filter((d) => d.id == "11001")
Insert cell
Insert cell
Insert cell
rawDataNoFips = rawData.filter((d) => d.fips === "")
Insert cell
rawnyc = rawData.filter((d) => d.county == "New York City")
Insert cell
nycCases = rawnyc[0].cases
Insert cell
nycDeaths = rawnyc[0].deaths
Insert cell
Insert cell
Insert cell
Insert cell
latestdata = data[data.length - 1]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
jsonData = (await fetch(url)).json()
Insert cell
pres2020 = FileAttachment("countypres_2020@2.csv").csv({ typed: false })
Insert cell
rec = pres2020.find((d) => d.FIPS == "06081" && d.Party === "REPUBLICAN")
Insert cell
pres2020.filter((d) => d.County == "BOX ELDER")
Insert cell
Insert cell
TrumpTotal = pres2020.filter(
(d) => d.Status == "TOTAL" && d.Candidate == "DONALD J TRUMP"
)
Insert cell
bentonCounty = pres2020.filter((d) => d.FIPS == "05007")
Insert cell
Insert cell
Insert cell
getRepublicanPct("46113")
Insert cell
pres2020.filter((d) => d.FIPS == "46113")
Insert cell
pres2020.find((d) => d.State == "ALASKA")
Insert cell
perCapitaTotals.filter((d) => d.state == "Alaska").map((d) => shrinkRecord(d))
Insert cell
perCapitaTotals.filter((d) => d.state == "Alaska")
Insert cell
Insert cell
pres2020.filter((d) => d.State == "ALASKA" && d.Party == "DEMOCRAT")
Insert cell
Insert cell
Insert cell
selectedStates
Insert cell
Insert cell
Insert cell
stateTitle()
Insert cell
perCapitaTotals.filter((d) => stateFilter(d))
Insert cell
selectedStates
Insert cell
totals.find((d) => d.population == "702455")
Insert cell
pres2020.find((d) => d.FIPS == "36005")
Insert cell
Insert cell
controlWidth = 0
Insert cell
Insert cell
width
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more