const svg = d3.select('body').append('svg') .attr('width', 256) .attr('height', 128); const rs = [1, Math.sqrt(2), 2]; const g = svg.selectAll('g').data(rs) .enter().append('g') .attr('transform', (d, i) => `translate(${80 * i + 15 * (d+1)},${128 / 2})`); g.append('circle') .attr('r', d => 15 * d) .attr('fill', 'blue'); g.append('text') .attr('dx', -10) .attr('dy', 50) .text(d => { const r = (d % 1 === 0) ? d : d.toFixed(2); return `r=${r}`; });