{
const size = width;
const context = DOM.context2d(size, size);
context.fillStyle = '#222';
context.fillRect(0, 0, size, size);
const range = config.n / 100000
const x = d3.scaleLinear().domain(d3.extent(nodes, n=> n[0] * 1.1)).range([0, size]);
const y = x;
const c = d3.scaleSequential(d3.interpolateSpectral).domain([0, Math.sqrt(config.n)]);
for (let i = 0; i < nodes.length; ++i) {
const [cx, cy] = nodes[i];
context.beginPath()
context.fillStyle = c(Math.sqrt(i)) ;
context.arc(
x(cx),
y(cy),
size / Math.sqrt(nodes.length) * config.size,
0,
2 * Math.PI
)
context.fill()
if (nodes.length < 100) {
context.fillStyle = 'white'
context.textAlign = 'center'
context.textBaseline = 'middle'
context.font = '10px Arial'
context.fillText(i, x(cx), y(cy))
}
}
return context.canvas;
}