score:2

Accepted answer

Keep a reference to the g you append and append the rects to it:

@svg = d3.select("body").append("g").attr("class", "geoms");
var g = @svg.append("g").attr("class", "value-labels");
g.append("rect").attr("class", "text").attr("width", 10).attr("height", 10).attr("x", 10).attr("y", 10);
g.append("rect").attr("class", "text").attr("width", 10).attr("height", 10).attr("x", 10).attr("y", 10);

Related Query