svg = {
let height = 600
const svg = DOM.svg(width,height)
let cx = width/2
let cy = height/2
let radius = radiusSlider
let circleCount = circleCountSlider
let circleArray = []
for (let i = 0; i< circleCount; i++){
circleArray[i] = (360/circleCount)*i
}
function toRadians(angle) {
return angle * (Math.PI / 180)
}
d3.select(svg).selectAll("circle")
.data(circleArray)
.enter()
.append("circle")
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", 1)
.attr("r", radius)
.attr("cx", d => cx+Math.sin(toRadians(d))*radius)
.attr("cy", function(d,i) {
if ( i <circleCount / 2) {
return (cy - radius) + Math.cos(toRadians(d))*radius
} else {
return (cy + radius) - Math.cos(toRadians(d))*radius
}
})
return svg
}