addTooltips(
Plot.plot({
width: 1000,
insetBottom: 40,
insetTop: 70,
projection: "albers",
marginBottom: 20,
marks: [
Plot.sphere({fill:"black", opacity: 1}),
Plot.geo(nation, {stroke:"#06c258",fill: "#97704f", opacity: 1, clip: "frame" }),
Plot.geo(states, {stroke: "black", clip: "frame", strokeOpacity: 1 }),
Plot.geo(states, {fill: d=> "#008080", opacity: 1, stroke: "black", title: (d)=> (d.properties.name) + "\n" + d.properties.common_name, filter: d=>d.properties.categoryemoji == category, fillOpacity: 2}),
Plot.text(['Is your State Amphibian\na Frog or a Salamander?'],{x:-84, y: 53, dx: 20, dy: 20, fontSize: 35, fill: "#008080", opacity: .8, lineHeight: 1.2, lineWidth: 50, fontStyle: "oblique", fontFamily: "italic", fontWeight: "bold"}),
Plot.text(['Data: wikipedia.org | Design: Deepsha Menghani\nThreads: @IandLoveandData | Mastodon: @Deepsha'],{x:-104, y: 24, dx: -180, dy: -20, fontSize: 15, fill: "gray", opacity: .7, lineHeight: 1.2, fontStyle: "oblique"}),
Plot.text(['🐸 - Frog'],{x:-104, y: 30, dx: -320, dy: -20, fontSize: 25, fill: "#008080", opacity: 1, lineHeight: 1.2, textAnchor: "start"}),
Plot.text(['🦎 - Salamander'],{x:-104, y: 30, dx: -320, dy: 25, fontSize: 25, fill: "#008080", opacity: 1, lineHeight: 1.2, textAnchor: "start"}),
Plot.text(
states.features,
Plot.centroid({
text: (d) => d.properties.emoji,
fontSize: 20,
textAnchor: "middle",
stroke: "white",
fill: "red",
title: (d) => d.properties.name + "\n" + d.properties.common_name,
filter: d=>d.properties.categoryemoji == category
})
)
]
}),
{ fill: "red", opacity: 0.5, "stroke-width": "4px", stroke: "red"}
)