chart = data => {
const arcs = pie(qMap);
const svg = d3
.create("svg")
.attr("viewBox", [-width / 2, -height / 2 - 20, width, height + 20]);
svg
.append('g')
.attr('transform', `translate(${-width / 2},${-height / 2})`)
.attr('font-family', 'sans-serif')
.attr('font-weight', 'bold')
.append('text')
.text(
'国際的な人の往来再開に向けた段階的措置等による入国者数 ' +
d3.timeFormat('%Y/%m/%d')(dates[0]) +
'–' +
d3.timeFormat('%Y/%m/%d')(dates[1])
);
svg
.append("g")
.attr("stroke", "white")
.selectAll("path")
.data(arcs)
.join("path")
.attr("fill", d => color(d.data[0]))
.attr("d", arc)
.append("title")
.text(d => `${d.data[0]}: ${d.data[1].toLocaleString()}`);
svg
.append("g")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.attr("text-anchor", "middle")
.selectAll("text")
.data(arcs)
.join("text")
.attr("transform", d => `translate(${arcLabel.centroid(d)})`)
.call(text =>
text
.filter(d => d.endAngle - d.startAngle > 0.25)
.append("tspan")
.attr("y", "-0.4em")
.attr("font-size", '2em')
.attr("font-weight", "bold")
.text(d => d.data[0])
)
.call(text =>
text
.filter(d => d.endAngle - d.startAngle > 0.25)
.append("tspan")
.attr("x", 0)
.attr("y", "0.7em")
.attr("font-size", '1.25em')
.attr("fill-opacity", 0.7)
.text(d => `${d.data[1].toLocaleString()}人`)
);
return svg.node();
}