score:0

Accepted answer

Yes you can do this, the code below shows how I am adding a translate to the g group on clicking of the button: (I have added comments for you to get a better picture of the code)

    //making a g group with in the circle
    var myG = d3.select("body").append("svg").attr("width", 500).attr("height", 500).append("g");
    //appending a circle to the g group.
    myG.append("circle").attr("cy", 60).attr("cx", 60).attr("r",10);

    var xTrans = 0;
    d3.select("#click").on("click", function() {
        xTrans+=20;
        //applying transform to g.
    	myG.attr("transform", "translate("+xTrans+",0)")
    });
circle{
   fill:steelblue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<button id="click">ClickToAddTransition</button>


Related Query

More Query from same tag