score:1

Accepted answer

I would either use a selection filter for this, filtering on the nodeName property of the element:

d3.selectAll("top_level_selector") //or use existing selection from appending
.filter(function(d,i){
    return this.nodeName == 'circle';
})
.attr("r", 12);

- https://github.com/mbostock/d3/wiki/Selections#wiki-filter

Or possibly just check inside the attribute function for correct nodetype :

selection
.attr('r',function(d,i){
    if(this.nodeName =='circle'){ return 12 }
});

I'm not positive but I don't think this will present a problem when it tries to assign an "r" attribute of undefined to the non-circle elements (and so on for 'points' on circle, etc).


Related Query