Plot.plot({
marginBottom: 90,
marginLeft: 60,
x: {
tickRotate: -30,
label: "Billionaire"
},
y: {
label: "↑ Amount Donated (US dollars, millions)",
transform: d => d / 1e6,
grid: true,
domain: [0, 250],
},
marks: [
Plot.text([{}], {
text: () => `Top 20 Largest Donations by Billionaires`,
frameAnchor: "top",
anchor: "middle",
dy: 0,
fontSize: 15,
fontWeight: "bold"
}),
Plot.text([{}], {
text: () => `2020 Election`,
frameAnchor: "top",
anchor: "middle",
dy: 18,
fontSize: 15,
fontWeight: "bold"
}),
Plot.ruleY([0]),
Plot.barY(data, {
x: "Billionaire",
y: "Amount Donated",
sort: { x: "y", reverse: true, limit: 20 },
fill: d => d.TechOrNot === "Technology" ? "darkgreen" : "#5dade2",
title: d => `Wealth Source: ${d["Wealth Source"]}\nIndustry: ${d.Industry}`,
tip: true
})
]
})