needed a simple circle legend for a bubble chart that I could pass in values and a domain
to initiate pass in a d3 selection to the circleLegend
function and your dataset domain
and values
:
var l = circleLegend(d3.select('svg g#legend'))
.domain([0, 100])) // the dataset min and max
.range( [0, 80]) // the circle area/size mapping
.values( [8, 34, 89]) // pass in values (e.g. min,mean/median & max)
// optional
.width(500) // it centers to this
.height( 500) // it centers to this
.suffix('') // ability to pass in a suffix e.g. '%'
.circleColor( '#888') // stroke of the circles
.textPadding(40) // left padding on text
.textColor( '#454545') // the fill for text
// and render it
l.render()
note: the number of values
you pass in will correlate to the number of circles
forked from eesur's block: d3 | reusable circle legend
forked from EndNight95's block: d3 | reusable circle legend