mbostock/d3 — pull request #1001 by ajtulloch (2013-01-09 08:23:32+00:00)
Title: Added d3.svg.transform, a way to construct SVG transform specifications

Constructing SVG transform specifications currently involves some somewhat ugly string concatenation - e.g.

.attr("transform", function(d) { return "transform(" + d.x + "," + d.y + ") rotate(" + d.r + ")"; })

This diff adds d3.svg.transform, a builder for SVG transform strings.
We can replace the above code by the simpler code:

.attr("transform", function(d) { return d3.svg.transform().translateX(d.x).translateY(d.y).rotate(d.r); })

or

.attr("transform", function(d) { return d3.svg.transform().translate([d.x, d.y]).rotate(d.r); })

See tests for other examples. Note that this does not implement the full SVG spec at http://www.w3.org/TR/SVG/coords.html#TransformAttribute,
only a subset determined by looking at how transforms are used in other D3 projects.