d2b › Text Wrap Pixels
This function is used to wrap svg text based on a threshold pixel width. Based on this block. This text wrap function is destructive on the internal tspan elements and thus causes problems when rebinding events on update like in the legend. For a less destructive function, see d2b.textWrap(), which uses d3's enter-update-exit process and is based on a character count threshold.
# d2b.textWrapPX(context, [width])
If width is provided, it will be used to set the pixel threshold where text wrapping should occur. The width defaults to
d3.select('svg text') .attr('y', 15) .text('A really really long label that needs to be wrapped.') .call(d2b.textWrapPX, 100);