funding = {
const plot = Plot.plot({
title: "Funding Gap by State",
subtitle: "Funding gap is defined as the gap in state education funding between actual spending and required spending per student.",
projection: "albers-usa",
width,
color: {
legend: true,
type: "diverging",
scheme: "PuOr",
label: "Education Funding",
tickFormat: (d) => {
if (d === -0.2) return "Underfunded";
if (d === 0) return "On Target";
if (d === 0.2) return "Overfunded";
return d;
}
},
caption: "Displaying data for 2019",
marks: [
Plot.geo(nation),
Plot.geo(statesFundingTopoJoinedWithEducationData, {
fill: (d) => d.properties.necm_fundinggap_state,
tip: true,
strokeOpacity: 0.25,
strokeWidth: 1,
title: (d) => `${d.properties.name}`
}),
Plot.dot(imagesDataset, {x: "lon", y: "lat", r: 5, fill: "white", stroke: "black", className: "imageDots"}),
Plot.text(imagesDataset, {x: "lon", y: "lat", text: "name", fill: "black", stroke: "white", paintOrder: "stroke", textAnchor: "middle", dy: -15}),
]
})
setTimeout(() => {
d3.selectAll(".imageDots circle")
.style("cursor", "pointer")
.on("mouseenter", (event, index) => {
mutable tooltipContent = {
url: imagesDataset[index].url,
pageX: event.pageX,
pageY: event.pageY
};
})
.on("mouseleave", () => {
mutable tooltipContent = null;
})
}, 0);
return plot;
}