Public
Edited
Sep 27, 2023
1 star
Insert cell
Insert cell
Insert cell
allData = await FileAttachment("policy_rate-1995-2023@3.csv").csv({typed: true})
Insert cell
usData = FileAttachment("policy_rate-us-1960-2023.csv").csv({typed: true})
Insert cell
// Since FileAttachment takes string literal only, we can only choose file by this work around
originalData = (csvFile == "policy_rate-1995-2023@1.csv") ? allData : usData
Insert cell
// Since two dates cannot compare, we need to convert to time first
dates = [...new Set(d3.map(originalData, d => d.Date.getTime()))].map(d => new Date(d))
Insert cell
areas = [...new Set(d3.map(originalData, d => d.Area))]
Insert cell
data = originalData.filter(d => selectedAreas.includes(d.Area))
.filter(d => d.Date.getTime() >= startDate.getTime())
Insert cell
d3.groups(data, d => d['Area'])
Insert cell
Insert cell
dateColumn = "Date"
Insert cell
nameColumn = "Area"
Insert cell
valueColumn = "Rate"
Insert cell
yAxisLabel = "Policy Rate"
Insert cell
height = 300
Insert cell
import { chart }
with {
data,
dateColumn,
nameColumn,
valueColumn,
yAxisLabel,
height
}
from "@chiahsun-ws/line-chart-multiple-series"
Insert cell
viewof csvFile = Inputs.radio(["policy_rate-1995-2023@1.csv", "policy_rate-us-1960-2023.csv"], {label: "Select one", value: "policy_rate-1995-2023@1.csv"})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart
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