map = {
let svg = viz.create({
projection: d3.geoNaturalEarth1()
});
let targetvalue = dotvalue;
let world = await FileAttachment("world.json").json();
let centroids = viz.tool.centroid(world);
let dots = viz.tool.replicate(centroids, {
field: "pop",
targetvalue: targetvalue * 1000000
});
let dodgedots = viz.tool.dodge(dots, {
projection: svg.projection,
r: radius,
iteration: 300
});
let typo = viz.tool.typo(
dodgedots.features.map((d) => d.properties.region),
{ colors: "Bold" }
);
svg.outline();
svg.path({ datum: world, fill: "white", fillOpacity: 0.3 });
svg.circle({
coords: "svg",
data: dodgedots,
r: radius,
fill: (d) => typo.colorize(d.properties.region)
});
viz.legend.typo_horizontal(svg, {
title: `1 dot = ${targetvalue} million inh.`,
pos: [480, 400],
alphabetical: true,
rect_width: 30,
rect_spacing: 10,
colors: typo.colors,
types: typo.types,
missing: false
});
return svg.render();
}