Public
Edited
Nov 15, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marginLeft: "100",
height: 600,
width: width * 1,
x: {
tickFormat: (d) => "" + d
},
y: {
domain:
ordering !== "good ordering"
? states
: [...states].sort(
(a, b) =>
linear_us_state_order.indexOf(b) -
linear_us_state_order.indexOf(a)
)
},
marks: [
Plot.cell(reparse(datum.find((d) => d.title == disease).data.values.data), {
x: "year",
y: "state",
fill: "rate",
height: "3px"
}),
Plot.tip(
reparse(datum.find((d) => d.title == disease).data.values.data),
Plot.pointerX({ x: "year", y: "state" })
)
]
})
Insert cell
reparse(datum[0].data.values.data)
Insert cell
function reparse(d) {
return d.map((x) => ({
year: +x[0],
stateid: x[1],
state: states[x[1]],
rate: x[2]
}));
}
Insert cell
datum = FileAttachment("datum.json").json()
Insert cell
import { linear_us_state_order } from "@bmschmidt/useful-linear-orders-for-countries-and-states"
Insert cell
import { state_info } from "@bmschmidt/state-info"
Insert cell
states.filter((s) => {
return !state_info.has(s);
})
Insert cell
states = [
"Alaska",
"Alabama",
"Arkansas",
"Arizona",
"California",
"Colorado",
"Connecticut",
"DC",
"Delaware",
"Florida",
"Georgia",
"Hawaii",
"Iowa",
"Idaho",
"Illinois",
"Indiana",
"Kansas",
"Kentucky",
"Louisiana",
"Massachusetts",
"Maryland",
"Maine",
"Michigan",
"Minnesota",
"Montana",
"Mississippi",
"Montana",
"NC",
"ND",
"Nebraska",
"NH",
"NJ",
"NM",
"Nevada",
"New York",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"SC",
"SD",
"Tennessee",
"Texas",
"Utah",
"Virginia",
"Vermont",
"Washington",
"Wisconsin",
"WV",
"Wyoming"
]
Insert cell
linear_us_state_order.indexOf("NJ")
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