function createCircle(visual) {
const circle1 = visual.append('circle')
.join('circle')
.attr('cx', 400)
.attr('cy', 250)
.attr('r', 150)
.style('fill', 'lightgreen')
.attr('opacity', 0.5)
.attr('id', 'circle1')
.attr('class', 'draggable');
let isDragging = false;
visual.selectAll('.draggable').call(d3.drag()
.on('start', function() {
isDragging = true;
d3.select(this).attr('stroke', 'orange')
d3.select(this).attr('stroke-width', '3');
})
.on('drag', function(event) {
if (isDragging) {
d3.select(this)
.attr('cx', event.x)
.attr('cy', event.y);
}
})
.on('end', function() {
isDragging = false;
d3.select(this).attr('stroke', null);
}));
d3.select('#circleSlider')
.on('input', function() {
let newRadius = this.value;
d3.select('#circle1')
.attr('r', newRadius);
});
}