Public
Edited
Jan 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("export.csv").csv({ typed: true })
Insert cell
Insert cell
Insert cell
Insert cell
data_tidy = data.reduce((previousValue, currentValue) => {
const date = currentValue["YDate"];

const categories = [
"ACM",
"ACN",
"Star",
"PL",
"PX",
"RB",
"Part",
"DebPRC",
"DebIr",
"Deb",
"Err"
];

const other_total = categories
.filter((d) => d !== "Star")
.map((d) => currentValue[d])
.reduce((previousValue_other, currentValue_other) => {
return previousValue_other + currentValue_other;
}, 0);

const other = {
date,
category: "Other",
value: other_total
};

const star = {
date,
category: "Star",
value: currentValue["Star"]
};

return [other, star, ...previousValue];
}, [])
Insert cell
Insert cell
Plot.plot({
width,
color: { legend: true, range: ["#36a9e1", "#eb5b25"] },
x: { domain: [2005, 2023], tickFormat: (d) => d },
y: { domain: [0, 4500], grid: true },
marks: [
Plot.areaY(
data_tidy.filter((d) => d.date >= 2005),
{ x: "date", y: "value", fill: "category" }
),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
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