chartElem = Plot.plot({
height: 540,
width: 600,
margin: 0,
projection: {
type: "azimuthal-equal-area",
domain: europeGeo,
inset: 16
},
marks: [
Plot.frame({ fill: "#f7fbfd" }),
Plot.geo(worldGeo2, {
fill: "#fff",
strokeWidth: 0.5,
stroke: "#cdcdcd"
}),
Plot.geo(europeGeo, {
fill: (d) =>
catDogMap.has(d.properties.NAME)
? catDogMap.get(d.properties.NAME).color
: "url(#diagonalHatch)",
fillOpacity: 0.8,
stroke: (d) =>
countryHighlight.includes(d.properties.NAME) ? "#222" : "#535353",
strokeWidth: (d) =>
countryHighlight.includes(d.properties.NAME) ? 1 : 0.5,
strokeOpacity: (d) => (catDogMap.has(d.properties.NAME) ? 1 : 0.2)
}),
(a, b, c, layout) =>
svg`
<g transform="translate(${layout.width - 106 - 48},${48 - 16})">
${Plot.plot({
height: 120,
width: 120,
margin: 0,
inset: 17,
marks: [
Plot.rect(d3.cross([0, 1, 2], [0, 1, 2]), {
x: ([a, b]) => a,
y: ([a, b]) => b,
interval: 1,
fill: ([a, b]) => colors[a + b * 3],
inset: -1,
stroke: "#222",
strokeWidth: 0.5
}),
Plot.text(["More dogs →"], {
fontWeight: "bold",
fontSize: 12,
x: 0,
y: 0,
rotate: 0,
textAnchor: "middle",
dx: 60 - 16,
dy: 10
}),
Plot.text(["More cats →"], {
fontWeight: "bold",
fontSize: 12,
x: 0,
y: 0,
rotate: 0,
textAnchor: "middle",
rotate: -90,
dx: -10,
dy: -60 + 16
})
]
})}
</g>`
]
})