Plot.plot({
width,
height: 600,
y: { percent: true },
color: { type: "ordinal", scheme: "set2", legend: true },
marks: [
Plot.areaY(
members,
Plot.stackY({
x: "date",
y: "seats",
z: "state",
fill: "joined",
order: "joined",
title: (d) => `${d.state}\nJoined ${d.joined}`,
stroke: "#fff",
strokeOpacity: 0.3,
offset: "expand",
curve: "monotone-x"
})
),
Plot.text(
members,
Plot.selectLast(
Plot.stackY({
filter: (d) => d.date < new Date(2020, 0, 1),
x: "date",
y: "seats",
z: "state",
fill: "joined",
order: "joined",
text: "state",
textAnchor: "start",
dx: -17,
fill: "#000",
offset: "expand"
})
)
)
]
})