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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more