Sri
Sri

Reputation: 181

D3 drawing circles on the circumference of other circle

I was trying to build a chart which is similar to here

https://sf.relsci.com/Visualizations/davos

How can i draw the circles in a circular shape?

Upvotes: 0

Views: 1234

Answers (1)

FernOfTheAndes
FernOfTheAndes

Reputation: 5015

Here is a FIDDLE with one way to do it.

.attr('transform', function (d, i) {
    return "translate(" + ((w/2-r) * Math.cos((interval*i) * Math.PI/180)) + "," + ((w/2-r) * Math.sin((interval*i) * Math.PI/180)) + ")";
});

Hope this helps.

Upvotes: 1

Related Questions