Public
Edited
Apr 18, 2023
Paused
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barX([...credit_count.entries()], {
x: (d) => d[1],
y: (d) => d[0],
fill: (d) => (d[0] === "Roger Waters" ? "steelblue" : "lightgrey"),
marginLeft: 90,
sort: { y: "x", reverse: true }
})
]
})
Insert cell
credit_count = d3.rollup(
writer_occurances,
(v) => v.length,
(d) => d
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
writer_occurances = pink_floyd_songs_augmented
.map((song) => song.writers)
.reduce((a, b) => a.concat(b), [])
Insert cell
pink_floyd_songs_augmented = {
return pink_floyd_songs.map((d) => ({
...d,
writers: clean_writers(d["Writer(s)"]),
vocalists: vocalists(d["Lead vocal(s)"])
}));
}
Insert cell
clean_writers = (s) => {
const writers_list = s.split("\n")

const clean_list = writers_list.map((s) => {
if (s === "Clare Torry[22]") return "Clare Torry";
if (
s ===
"Richard Wright (Credited to David Gilmour, Nick Mason, Roger Waters, Richard Wright)"
)
return "Richard Wright";
return s;
});

return clean_list
}
Insert cell
vocalists = (s) => {
const vocalists_list = s.split("\n");
return vocalists_list;
}
Insert cell
Insert cell
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