Public
Edited
Jan 23, 2023
Insert cell
chart(data)
Insert cell
Insert cell
dates = [...monthsAgo({ month: "december", year: 2022 }, 12)].reverse()
Insert cell
Insert cell
import { monthsAgo } from "2c005d0428e381b8"
Insert cell
db = "https://int-cpi-datasette-proxy.vir.onservo.com/cpi/month-by-month.json"
Insert cell
chart = function (data, domain) {
return Plot.plot({
grid: true,
inset: 10,
width,
height: 25 * 200,
x: {
nice: true,
tickFormat: (d) =>
d.toLocaleString("en", { month: "short", year: "2-digit" })
},
y: {
nice: true,
ticks: 10,
domain: d3.extent(data, (d) => d.change)
// domain: d3.extent(
// data.filter((f) => domain.includes(f.label)).map((f) => f.change)
// )
},
// fy: {
// domain
// },
facet: {
data,
y: "label",
marginRight: 275
},
marks: [
Plot.frame(),
Plot.line(data, {
x: "date",
y: "change"
}),
Plot.dot(data, {
x: "date",
y: "change",
fill: "steelblue"
})
]
});
}
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