Я пытаюсь использовать d3 для рисования элементов круга с ярлыками рядом с ними. Я должен уметь перемещать круг с меткой рядом с ним.D3 Ярлык для перетаскиваемого круга
Любые советы приветствуются. https://jsfiddle.net/o3yg8sq1/2/
const svg = d3.select('svg'),
width = +svg.attr('width'),
height = +svg.attr('height');
const node = svg.append('g')
.attr('class', 'nodes')
.selectAll('circle')
.data([{1:1},{2:2}])
.enter().append('circle')
.attr('r', 15)
.attr('cx', function (d, i) { return Math.random() * 100; })
.attr('cy', function (d, i) { return Math.random() * 100; })
.call(d3.drag()
.on('drag', dragmove));
svg.selectAll('.nodes')
.append('text')
.text(function(d){return 'test';})
function dragmove(d) {
d3.select(this).attr('cx', d3.event.x);
d3.select(this).attr('cy', d3.event.y);
}