chartElem = Plot.plot({
height: 540,
width: 600,
margin: 0,
projection: {
type: "azimuthal-equal-area",
domain: nutsGeo,
inset: 8
},
marks: [
Plot.frame({ fill: "#f7fbfd" }),
() =>
svg`
<defs>
<filter id="shadow" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="0" dy="0" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="4" />
<feComponentTransfer result="opacityOut" in="blurOut">
<feFuncA type="linear" slope="0.3"/>
</feComponentTransfer>
<feBlend in="SourceGraphic" in2="opacityOut" mode="normal" />
</filter>
<pattern id="diagonalHatch" patternUnits="userSpaceOnUse" width="4" height="4">
<path d="M-1,1 l2,-2
M0,4 l4,-4
M3,5 l2,-2"
style="stroke:#eeeeee; stroke-width:1" />
</pattern>
</defs>
`,
// base map
Plot.geo(worldGeo, {
fill: "#fff",
strokeWidth: 0.5,
stroke: "#cdcdcd"
}),
// outline of data map
/*
Plot.geo(nutsGeo, {
fill: "#fff",
stroke: "#222",
strokeOpacity: (d) => (d.id.length === 2 ? 1 : 0),
imageFilter: "url(#shadow)"
}),*/
// missing data map
Plot.geo(nutsGeo, {
fill: "url(#diagonalHatch)"
}),
// data map
Plot.geo(nutsGeo, {
fill: (d) =>
gdpMilMap.has(d.id) ? gdpMilMap.get(d.id).color : "transparent"
}),
// country (data) level outline map
Plot.geo(nutsGeo, {
stroke: (d) => (d.properties.LEVL_CODE === 0 ? "#222" : "none"),
strokeOpacity: 0.4
}),
// legend
(a, b, c, layout) =>
svg`
<g transform="translate(${layout.width - 106 - 48},${48 - 16})">
${Plot.plot({
height: 120,
width: 120,
margin: 0,
inset: 16,
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],
stroke: "#222"
}),
Plot.text(["GDP →"], {
fontWeight: "bold",
fontSize: 14,
x: 0,
y: 0,
rotate: 0,
textAnchor: "middle",
dx: 60 - 16,
dy: 10
}),
Plot.text(["MILITARY →"], {
fontWeight: "bold",
fontSize: 14,
x: 0,
y: 0,
rotate: 0,
textAnchor: "middle",
rotate: -90,
dx: -10,
dy: -60 + 16
})
]
})}
</g>`
]
})