Public
Edited
May 19
Insert cell
Insert cell
chart = Plot.plot({
width: 600,
height: 600,
marginTop: 50,
marginLeft: 70,
x: {
label: "Year",
type: "band"
},
y: {
label: "Contributions (USD)",
tickFormat: d => {
if (d >= 1e9) return (d / 1e9).toFixed(1) + "B"; // billions
if (d >= 1e6) return (d / 1e6).toFixed(1) + "M";
return d; // raw numbers
},
grid: true
},
marks: [
Plot.text([{}], {
text: () => `Donations During U.S. Federal Election Cycles By Billionaires`,
frameAnchor: "top",
anchor: "middle",
dy: -30,
fontSize: 12,
fontWeight: "bold"
}),
Plot.text([{}], {
text: () => `source: americansfortaxfairness.org`,
frameAnchor: "top",
anchor: "middle",
dy: -12,
fontSize: 12,
}),
Plot.ruleY([0]),
Plot.barY(donation_data, {
x: "Year",
y: "Contributions",
title: d => `$${d3.format(",")(d.Contributions)}`,
fill: "seagreen",
tip: true
})
]
})

Insert cell
donation_data = FileAttachment("donation_data.csv").csv()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more