{
for (let i = 0; i < 200; i++){
simulation.tick();
}
const fills = world.features.map((ft, i) => {
const value = getValue(ft.properties.ISO_A3);
return {
index: i,
ISO3: ft.properties.ISO_A3,
POP_EST: ft.properties.POP_EST,
x: ft.x,
y: ft.y,
radius: r(ft.properties.POP_EST),
startAngle: 0,
endAngle: value/10 * tau,
padAngle: 0,
value: value/10
}
});
const bases = world.features.map((ft, i) => {
return {
index: i,
ISO3: ft.properties.ISO_A3,
POP_EST: ft.properties.POP_EST,
x: ft.x,
y: ft.y,
radius: r(ft.properties.POP_EST),
startAngle: 0,
endAngle: tau,
padAngle: 0,
value: 1
}
})
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("overflow", "visible");
svg.selectAll(".country")
.data(world.features)
.enter().append("path")
.attr("class", "country")
.attr("d", path)
.attr("fill", "#f5f5f5")
.attr("opacity", 0.7)
.attr("stroke", "#e0e0e0")
.style("display", show === "show" ? "block" : "none");
svg.selectAll('path.base')
.data(bases)
.join('path')
.attr('class', "base")
.attr('transform', function(d) { return 'translate(' + [d.x, d.y] + ')'; })
.attr("fill", "#d6d6d6")
.attr("d", d => d3.arc().innerRadius(d.radius * 0.67).outerRadius(d.radius - 1)(d));
svg.selectAll('path.filled')
.data(fills)
.join('path')
.attr('class', "filled")
.attr('transform', function(d) { return 'translate(' + [d.x, d.y] + ')'; })
.attr("fill", d => colorScale(d.value))
.attr("d", d => d3.arc().innerRadius(d.radius * 0.67).outerRadius(d.radius - 1)(d));
return svg.node();
}