Public
Edited
Mar 8, 2023
Insert cell
Insert cell
data = FileAttachment("inflation.csv").csv({ typed: true })
Insert cell
Insert cell
Plot.plot({
marks: [Plot.ruleY([0]), Plot.lineY(data, { x: "date", y: "value" })]
})
Insert cell
Plot.plot({
marks: [Plot.linearRegressionY(data, { x: "date", y: "value" })]
})
Insert cell
viewof selectedIndex = Inputs.range([0, data.length - 1], { step: 1, })
Insert cell
selectedDate = data[selectedIndex].date
Insert cell
function deflate(dataIndex, amount) {
return (data[data.length - 1].value / data[dataIndex].value) * amount;
}
Insert cell
poundToday = deflate(selectedIndex2, 1)
Insert cell
viewof selectedDate2 = Inputs.select(data.map((x) => x.date))
Insert cell
selectedIndex2 = data.findIndex((x) => x.date == selectedDate2)
Insert cell
## What's a ${selectedDate2.getFullYear()} £1 worth today?
The answer is... £${poundToday.toFixed(2)}!
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