Published
Edited
Jun 30, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
top50MyOwn = {
let data;
let tracks = await spotifyApi.getMyTopTracks({
limit: 50,
time_range: selectedRange[0]
});
tracks = tracks.items.map((d) => ({ id: d.id, name: d.name }));
return await features(tracks);
}
Insert cell
featuresTop50Global = features(top50Global)
Insert cell
Insert cell
featuresKeys = Object.keys(top50Combined[0])
.slice(1, 11)
.filter((i) => i != "key" && i != "loudness")
Insert cell
featuresPivot = featuresKeys.flatMap((feature) =>
top50Combined.map((d) => ({ scope: d.scope, feature, value: d[feature] }))
) //using flatMap to pivot the feature values so that we can use it in d3
Insert cell
import { StackedBarChart } from "@d3/stacked-bar-chart"
Insert cell
import { GroupedBarChart } from "@d3/grouped-bar-chart"
Insert cell
import { Legend, Swatches } from "@d3/color-legend"
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