I am rendering SVG image dynamically and created rotated text. If the rotated text is overlap with other text, i need to remove that text. But i can't measure the rotated text to create bounds and check with next label text region.
I have created 3 SVG element to explain.
- SVG-1 Shows the overlapped text.
- SVG-2 Shows the rotated text with overlapped (Angle-10)
- SVG-3 Shows the rotated text without overlapping (Angle-50)
I will rotate the text to any angle dynamically. If it is overlapped while rotating text, I need to remove that overlapped text programmatically .
<div style=" width: 150px;height: 150px;">
<svg style="width: 250px; height: 144px; border: solid black 1px;">
<text id="XLabel_0" x="75" y="30">Sprint 13_March_2015</text>
<text id="XLabel_1" x="100" y="30">DT_Apr2015_Sprint13</text>
</svg>
<svg style="width: 250px; height: 144px; border: solid black 1px;">
<text id="Label_0" x="75" y="30" transform="rotate(10, 75, 34.5)">Sprint 13_March_2015</text>
<text id="XLabel_1" x="100" y="30" transform="rotate(10, 100, 34.5)">DT_Apr2015_Sprint13</text>
</svg>
<svg style="width: 250px; height: 144px; border:solid black 1px;">
<text id="XLabel_0" x="75" y="30" transform="rotate(50,94,34.5)">Sprint 13_March_2015</text>
<text id="XLabel_1" x="100" y="30" transform="rotate(50,123,61)" >DT_Apr2015_Sprint13</text>
</svg>
</div>
Can anyone suggest a solution?
It can be kinda tricky, but you can compute polygons for each text element, and then see if they intersect. I used one of your labels in the example below: