Proportional circle areas?

279 views
Skip to first unread message

Dan

unread,
Jan 19, 2012, 9:37:58 AM1/19/12
to d3-js
How do I define a D3 radius scale so that the areas of the circles
will be proportional? (This should be easy but my scale is off by a
few pixels ... Perhaps it is a rounding issue ...?)

attr("r", function(d){ return rScale(d.value) })

Mike Bostock

unread,
Jan 19, 2012, 11:02:33 AM1/19/12
to d3...@googlegroups.com
> How do I define a D3 radius scale so that the areas of the circles
> will be proportional?

Generally by using a d3.scale.sqrt, and by setting the lower bound of
the domain and range to 0. For example:

var r = d3.scale.sqrt()
.domain([0, 5000])
.range([0, 20]);

Mike

Reply all
Reply to author
Forward
0 new messages