plotPathMap = ({ artists }) => {
return addTooltips(
Plot.plot({
caption: "Click to open artist on Spotify",
width,
height: height * 0.8,
color: {
legend: true,
domain: [...clusterMap.scale("color").domain, "#0000FF"]
},
x: xScale,
y: yScale,
marks: [
hull,
Plot.density(
hydratedArtists.filter((a) => a.center_of_mass),
{
x: (d) => d.center_of_mass.x,
y: (d) => d.center_of_mass.y,
fill: (d) => d.from_playlist.name,
fillOpacity: 0.03,
clip: true
}
),
Plot.line(artists, {
x: (d) => d.center_of_mass.x,
y: (d) => d.center_of_mass.y,
curve: "catmull-rom",
marker: "arrow"
}),
on(
Plot.image(artists, {
x: (d) => d.center_of_mass.x,
y: (d) => d.center_of_mass.y,
src: (d) => (_.last(d.images) ? _.last(d.images).url : undefined),
width: (d) => 24,
title: (artist) => makeArtistTooltip({ artist })
}),
{
click: (event, d) =>
window.open(d.datum.external_urls.spotify, "_blank")
}
),
Plot.text(artists, {
x: (d) => d.center_of_mass.x,
y: (d) => d.center_of_mass.y,
fill: "blue",
href: (d) => d.external_urls.spotify,
target: () => "_blank",
text: (d) => d.name,
dy: -15
})
]
})
);
}