mbostock/d3 — pull request #649 by dadleyy (2012-05-20 17:59:30+00:00)
Title: passing object into .attr()

normally, the .attr() function forces coders to have quite long strings of .attr(key,value) snippets.

It would look like:

d3.select('#svg').append('circle').attr('r',50).attr('fill','#fff').attr('stroke','#f00');

Changing the function a little bit, it can operate more like the jQuery .css() function. Coders can pass an object of `key : value` pairs that will be looped through and called as a single .attr() command.

the new code looks like

d3.select('#svg').append('circle').attr({
"r" : 20,
"fill" : "red",
"stroke" : "#fff",
});