Public
Edited
Jan 14, 2024
Insert cell
Insert cell
cpi.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
cpi.forEach((d, i) => {
d.aucslChange = 0
d.lfeslChange = 0
if (i >= 12) {
d.aucslChange = (d.CPIAUCSL - cpi[i - 12].CPIAUCSL) / cpi[i - 12].CPIAUCSL
d.lfeslChange = (d.CPILFESL - cpi[i - 12].CPILFESL) / cpi[i - 12].CPILFESL
}
})
Insert cell
cpi
Insert cell
cpiData = cpi.filter(d => (d.observation_date.getUTCFullYear() > 2014))
Insert cell
cpidf = aq.from(cpiData).view()
Insert cell
Plot.plot({
height: 423,
width: 650,
y: {
grid: true,
ticks: 6,
domain: [-0.02, 0.1],
tickFormat: "%"
},
marks: [
Plot.axisX({
label: null,
tickFormat: (d) => {
const year = d.getUTCFullYear();
if (year === 2015) {
return year;
}
if (year === 2020) {
return "'20";
}
}
}),
Plot.ruleY([0]),
Plot.line(cpiData, {
x: "observation_date",
y: "lfeslChange",
stroke: "#bb2b77",
strokeWidth: 2,
strokeLinecap: "square",
strokeLinejoin: "bevel"
}),
Plot.line(cpiData, {
x: "observation_date",
y: "aucslChange",
stroke: "#323232",
strokeWidth: 2,
strokeLinecap: "round",
strokeDasharray: "0.1 5"
})
]
})
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