Plot.plot({
width: 1152,
height: sort === "Date" ? 760 : 680,
insetLeft: 10,
insetRight: 60,
r: {range: [0,80]},
marks: [
Plot.frame({anchor: "bottom"}),
Plot.dot(
fails,
Plot.dodgeY({
sort,
anchor: "bottom",
padding: 2,
x: "Date",
r: d => d["Assets"],
title: (d) => `${d["Bank Name"]}\n${(d["Assets"] / 1000).toFixed(1)}B`,
fill: "#ddd",
stroke: "#000",
strokeWidth: 1
})
),
Plot.text(
fails,
Plot.filter((d) => d.Assets > 2000, Plot.dodgeY({
sort,
anchor: "bottom",
padding: 2,
x: "Date",
lineWidth: 5,
r: d => d["Assets"],
text: (d) => d.Assets > 64500
? `${d["Bank Name"]}\n${(d["Assets"] / 1000).toFixed(0)}B`
: `${(d["Assets"] / 1000).toFixed(1)}`,
pointerEvents: "none",
fill: "#000",
stroke: "#ddd"
}))
)
]
})