Plot.plot({
width: width,
height: width*.6,
label: null,
color: { range: ["#8E8E8E", "#DF8FB6"] },
marks: [
Plot.gridX({
strokeDasharray: "3,4",
strokeOpacity: 0.6
}),
Plot.barX(dataset, {
x: (d) => d.value,
y: (d) => d.State,
sort: { y: "x" },
fill: (d) => d.value > 0,
stroke: (d) => (d.value > 0 ? "#CC5B88" : "#4C4C4C"),
strokeWidth: 1,
insetTop: 3,
insetBottom: 3,
tip: "y",
className:"whatsgoingon",
rough: {
id: "I-am-an-id",
roughness: 1,
bowing: 1,
fillStyle: "hachure"
}
}),
d3
.groups(dataset, (d) => d.value > 0)
.map(([growth, states]) => [
Plot.axisY({
x: 0,
ticks: states.map((d) => d.State),
tickSize: 0,
anchor: growth ? "left" : "right"
}),
Plot.textX(states, {
x: "value",
y: "State",
text: (
(f) => (d) =>
f(d.value)
)(d3.format("+.1%")),
textAnchor: growth ? "start" : "end",
dx: growth ? 4 : -4
})
])
]
})