I can't figure how to place a path relative to its sibling path's bounding box. Imagine a box like a window and I want to put a close button to the top right corner of it. Here is the box and close button grouped together after transforming the window (scaling it 3x):
<g id="group24">
<path id="path24" fill="#00aa00" stroke="#00ff00" stroke-width="4" stroke-miterlimit="10" d="M301,585.08v47h45.834l-0.134-21.8
l12.3-0.2l-1-239H253v216c0,0,22,0.2,22,0c0-41,26-31.357,26-31.357V585.08L301,585.08z" transform="matrix(3,0,0,3,-612,-1003.16)"></path>
<path id="close-button" fill="#B40000" d="M256,232c-13.255,0-24,10.745-24,24s10.745,24,24,24s24-10.745,24-24
S269.255,232,256,232z M265.102,270.277l-8.985-8.984l-8.985,8.985l-4.826-4.829l8.983-8.984l-8.984-8.984l4.829-4.826l8.983,8.982
l8.981-8.983l4.83,4.827l-8.983,8.983l8.984,8.983L265.102,270.277z"></path>
</g>
I just append the button after transforming the box (animate callback) to the group24 group dynamically and close button appears like this:
And after when I get the bounding box of the path24 element in group and try to position the close button to the top right:
var p = this.SvgButton.select("path");
var bbox = myBox.getBBox();
var coordString = (bbox.x2 - 10) + " " + (bbox.y);
p.transform("T" + coordString);
the coordinates are always wrong. How can I position the close button to the top right corner of the lightgreen box?
An example of what I'm trying to achieve is here: http://jsfiddle.net/savpm8w3/1/ Note that scale animation doesn't work in jsfiddle and thats why the example in fiddle works.