Public
Edited
Dec 8, 2023
1 fork
Insert cell
Insert cell
viewof file = Inputs.file({label: "Data"})
Insert cell
data = file.json()
Insert cell
datamap = data.reduce((acc, cur) => {
if (acc[cur.year] == undefined) {
acc[cur.year] = 0;
}
acc[cur.year] += 1;
return acc;
}, {})
Insert cell
plottable = {
let res = [];
for (let year in datamap) {
res.push({ year: parseInt(year), count: datamap[year] });
}
return res;
}
Insert cell
plottable[0].year
Insert cell
justnewer = plottable
.filter((e) => e.year > new Date(2000))
.map((e) => ({ year: new Date(`1/1/${e.year}`), count: e.count }))
Insert cell
Plot.plot({
grid: true,
title: "Cluster users publications per year",
marginLeft: 70,
marks: [
Plot.barX(justnewer, {
x: "count",
y: "year",
sort: { y: "x", reverse: false }
}),
Plot.text(justnewer, {
x: "count",
y: "year",
text: "count",
dx: 10
}),
Plot.ruleX([0])
]
})
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