I am trying to get my labels to wrap correctly. I need to get the ticks and labels to match up. I am using a wrap function for the labels but could not get it to work with the tspans.
WORKING DEMO
UPDATE
Here is before and after picture to help understand what Im after.
Sadly there is no simple way to get SVG <text>
elements' content to wrap like it would in HTML. However I did find this answer to a similar question which suggests using the D3 Plus library to add text wrapping to D3.
If for some reason that isn't an option you will probably have to calculate the wrapping yourself, it is a bit of a nasty process but is doable with some effort. In general terms you need to:
<tSpan>
elements to output each line of text (you'll have to manually set the top offset for each new line)I'd definitely advise using the library though if at all possible!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With