{
const boxHeight = 300;
const svg = d3.create('svg').attr('viewBox', [0, 0, width, boxHeight]);
let arr = [...Array(d3.randomInt(2, 11)())];
const nodes = arr.map(a => {
const r = d3.randomUniform(10, 50)();
const red = d3.randomInt(1, 256)();
const green = d3.randomInt(1, 256)();
const blue = d3.randomInt(1, 256)();
const alpha = Math.random();
return {
x: d3.randomUniform(r, width - r)(),
y: d3.randomUniform(r, boxHeight - r)(),
r: r,
color: d3.rgb(red, green, blue, alpha)
};
});
svg
.selectAll('circle')
.data(nodes)
.join('circle')
.attr('cx', d => d.x)
.attr('cy', d => d.y)
.attr('r', d => d.r)
.attr('fill', d => d.color);
return svg.node();
}