Plot.plot({
marks: [
Plot.barX(
purchases,
Plot.groupY(
{ x: "sum" },
{
filter: (d) => d.category == select,
x: "price_in_usd",
y: "name",
fill: "category",
sort: { y: "x", reverse: true, limit: 20 }
}
)
),
Plot.text(
purchases,
Plot.groupY(
{ x: "sum", text: "sum" },
{
filter: (d) => d.category == select,
x: "price_in_usd",
y: "name",
text: "price_in_usd",
textAnchor: "start",
dx: 5
}
)
),
Plot.ruleX([0])
],
color: { ...categoryChart.scale("color"), legend: true, columns: "100px" },
marginLeft: 200,
marginRight: 100
})