Public
Edited
Oct 21, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
senateResultsRaw.filter(d => ['r_out_of_cycle','d_out_of_cycle'].includes(d.status)).map(d => d.district.replace('SD ',''))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// houseDistricts = renderedHouseCartogramDims.districts.features.map(d => ({district: d.properties.district, status: "pending"}))
Insert cell
// senateDistricts = renderedSenateCartogramDims.districts.features.map(d => {
// const lastRace = d.properties.legislativeElections.sort((a,b) => b.year - a.year)[0]
// const inCycle2022 = lastRace.year === '2018'
// const incumbentParty = lastRace.winnerParty
// return {
// district: d.properties.district,
// status: inCycle2022 ? "pending" : `${lastRace.winnerParty.toLowerCase()}_out_of_cycle`,
// }
// })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// candidates = {
// const raw = await FileAttachment("2022-general-legislative-candidates.csv").csv()
// const cleaned = raw.map(d => {
// let chamber, district
// const number = +d.Office.replace('Senate District ','').replace('House District ','')
// if (d.Office.includes('Senate District')) {
// chamber = 'senate'
// district = 'SD ' + number
// }
// if (d.Office.includes('House District')) {
// chamber = 'house'
// district = 'HD ' + number
// }
// return {
// name: d.Name,
// party: d.Party,
// chamber,
// number,
// district,
// }
// })
// return cleaned
// }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
format = ({
n: d3.format(',.0f'),
p: d3.format('.0%')
})
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