changePercStates = {
return addTooltips(
Plot.plot({
width,
projection: "identity",
color: {
type: "quantize",
n: 10,
scheme: "RdBu",
label: "Change in Jobs from 2022 to 2034 (%)",
legend: true,
tickFormat: (d) => `${(d * 100).toFixed(0)}%`
},
caption: caption(
"Data Source: [Powered by Lightcast Data](http://www.lightcast.io)"
),
marks: [
Plot.geo(
states,
Plot.centroid({
tip: false,
fill: (d) => change2034perc.get(d.id),
title: (d) => {
const stateName = statemap.get(d.id.slice(0, 2)).properties.name;
const changeLabel = change2034.get(d.id);
const changePercentage = change2034perc.get(d.id);
const jobs2022label = jobs2022.get(d.id);
const jobs2034label = jobs2034.get(d.id);
return `${stateName}\nJobs (2022): ${Math.round(
jobs2022label
).toLocaleString()}\nJobs (2034): ${Math.round(
jobs2034label
).toLocaleString()}\nChange: ${Math.round(
changeLabel
).toLocaleString()}\n Percentage Change: ${(
changePercentage * 100
).toFixed(1)}%`;
}
})
),
Plot.geo(states, { stroke: "grey", strokeWidth: 1 })
]
}),
{
stroke: "black",
"stroke-width": "3px"
}
);
}