Plot.plot({
width: 928,
height: 500,
x: { label: null },
y: { tickFormat: "s", tickSpacing: 50, label: null },
color: { scheme: "Spectral" },
marks: [
Plot.barY(tidy, {
x: "state",
y: "population",
fill: "age",
sort: {color: null, x: "-y"},
tip: true,
title: (d) => `${d["population"]} people ${d["age"]} years old in ${d["state"]} with a very long string`
}),
Plot.text(
tidy,
Plot.pointerX(
renameXYPxPy(
Plot.stackY({
x: "state",
y: "population",
frameAnchor: "top-left",
dy: -20,
text: (d) =>
`${d["population"]} people ${d["age"]} years old in ${d["state"]}`
})
)
)
)
]
})