Skip to content

Instantly share code, notes, and snippets.

View TFM-LSW's full-sized avatar

Lee Walters TFM-LSW

  • Bristol, UK
View GitHub Profile
@TFM-LSW
TFM-LSW / README.md
Last active August 29, 2015 14:16 — forked from davelandry/README.md

Using d3plus.textwrap, SVG <text> elements can be broken into separate <tspan> lines, as HTML does with <div> elements. In this example, the first column shows normal wrapped text, the second column shows text that is resized to fill the available space, and the third column shows the default SVG behavior.

D3plus automatically detects if there is a <rect> or <circle> element placed directly before the <text> container element in DOM, and uses that element's shape and dimensions to wrap the text. If it can't find one, or that behavior needs to be overridden, they can manually be specified using .shape( ), .width( ), and .height( ).

Featured on D3plus.org