mainmap = addTooltips( // Add tooltips
Plot.plot({
projection: "equal-earth", // Set the projection
// width: 1200,
marks: [
Plot.geo(
countries, {
fill: (d) => countries_status.get(d.properties.NAME_ENGL), stroke: "white", // Add county boundaries using the geo mark
title: (d) =>
`${d.properties.NAME_ENGL} \n ${countries_status.get(d.properties.NAME_ENGL)} \n Score: ${countries_total.get(d.properties.NAME_ENGL)}`, // Custom tooltip text
opacity: .5
}),
// Plot.text(countries, Plot.centroid({text: d => countries_name.get(d.properties.NAME_ENGL), fill: "black", stroke: "white"})),
],
color: {
range: ["#309ebe", "#df3144", "#ffde75", "#eeeeee"],
// domain: ["Free", "Not free", "Partially free", "no data"],
unknown: "#ddd", // Polygons with unknown values are gray
type: "categorical", // Linear scale for color progression
legend: true, // Add the legend
label: "SOI country status", // Update legend label
},
}),
// tooltip style
{opacity: 1, stroke: "#000000"}
)