function drawPlot(data, container) {
const plot = Plot.plot({
width: 1050,
projection: {
type: "azimuthal-equidistant",
rotate: [0, -90],
domain: d3.geoCircle().center([0, 90]).radius(6.25)()
},
color: { legend: true },
marks: [
Plot.geo([5, 4, 3, 2, 1], {
geometry: (r) => d3.geoCircle().center([0, 90]).radius(r)(),
stroke: "black",
fill: "black",
strokeOpacity: 0.3,
fillOpacity: 0.03,
strokeWidth: 0.5
}),
Plot.link(longitude.domain(), {
x1: longitude,
y1: 90 - 5.7,
x2: 0,
y2: 90,
stroke: "white",
strokeOpacity: 0.5,
strokeWidth: 2.5
}),
Plot.text([3, 4, 5], {
x: 180,
y: (d) => 90 - d,
dx: 2,
textAnchor: "start",
text: (d) => `${20 * d}%`,
fill: "currentColor",
stroke: "white",
fontSize: 8
}),
Plot.text(longitude.domain(), {
x: longitude,
y: 90 - 5.7,
text: Plot.identity,
fontSize: 15,
lineWidth: 5
}),
() =>
svg`<style>
g[aria-label=area] path {fill-opacity: 0.1; transition: fill-opacity .2s;}
g[aria-label=area]:hover path:not(:hover) {fill-opacity: 0.05; transition: fill-opacity .2s;}
g[aria-label=area] path:hover {fill-opacity: 0.3; transition: fill-opacity .2s;}
`,
Plot.area(data, {
x1: ({ key }) => longitude(key),
y1: ({ value }) => 90 - value,
x2: 0,
y2: 90,
fill: "Company",
stroke: "Company",
curve: "cardinal-closed"
}),
Plot.dot(data, { x: "key", y: "value", fill: "Company" }),
Plot.text(
data,
Plot.pointer({
x: ({ key }) => longitude(key),
y: ({ value }) => 90 - value,
text: (d) => `${(20 * d.value).toFixed(0)}%`,
textAnchor: "start",
dx: 4,
fill: "currentColor",
stroke: "white",
maxRadius: 20
})
)
]
});
container.innerHTML = "";
container.appendChild(plot);
}