I am Rendering shape name at bottom center of shape something like this. (Shape name is dynamic)
First approach---> I tried to render Shape name inside of Group of Shape but the problem i am facing when text name length increase it start affecting shape width. So i move to another way
Second Approach---> I have move Group of Shape name Outside group of Shape with same position of Shape. Here is my calculation for this
//on name change this will make move rechtangle to exact x position
if (shapeRef.current?.attrs?.x) {
nameRef?.current?.parent.x(
shapeRef.current?.attrs?.x - (nameRef?.current?.textWidth + 4) / 2
);
}//this will move Child group same as shape group
if (shapeRef.current?.attrs?.y) {
nameRef?.current?.parent?.y(
shapeRef.current?.attrs?.y +
shapeRef?.current?.attrs?.height / 2 -
7
);
}//This will move shape to bottom area
This is working perfectly fine until i introduce rotation as soon as Parent rotation change This calculations fails as now i Need to move some time x and sometime y.
Here is example code