Published
Edited
Nov 13, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tooltipContents = d =>
`${statesGeoByFips.get(d.id).properties.name}: ${
d.value !== null && d.value >= 0 ? d.value : "not included"
}`
Insert cell
mapData = statesGeo.features.map(d => ({
id: d.id,
value: getValue(d)
}))
Insert cell
getValue = geo => {
const datum = statesTopN.find(d => d.state === geo.properties.name);
if (datum) return datum.combined_score;
return null;
}
Insert cell
statesTopN = dataStates.sort(sorter).slice(0, topN)
Insert cell
colorScale = d3.scaleSequential(colorInterpolator).domain(colorDomain)
Insert cell
colorInterpolator = stateOrderPicker === "Least"
? t => d3.interpolateBuGn(1 - t)
: d3.interpolateYlOrRd
Insert cell
colorDomain = d3.extent(statesTopN, d => d.combined_score)
Insert cell
stateOrderPickerOptions = ["Least", "Most"]
Insert cell
sorter = stateOrderPicker === "Least" ? sortAsc : sortDesc
Insert cell
sortAsc = (a, b) => a.combined_score - b.combined_score
Insert cell
sortDesc = (a, b) => b.combined_score - a.combined_score
Insert cell
Insert cell
import { html, svg } from "@observablehq/htl"
Insert cell
import { legend } from "@d3/color-legend"
Insert cell
import { select, slider } from "@jashkenas/inputs"
Insert cell
import {
drawChoroplethMap,
statesGeoByFips,
statesGeo
} from "@clhenrick/reusable-county-choropleth-map"
Insert cell
import {
dataStates,
dataCounties
} from "@clhenrick/het-data-intake-covid-19-community-vulnerability-index-ccv"
Insert cell
d3 = require("d3@6")
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