This example, using satirical data from The Onion, demonstrates how to wrap long axis labels to fit on multiple lines.
Update (jimkang): Added a data accessor function as a parameter to mbostock's wrap() so that it can fetch the text from the data source rather than using text().
The problem with text() is that it is built on textContent which "returns the text content of this node and its descendants." If a text element has several tspan descendants, it joins their contents without spaces. e.g. a text element with three tspans each containing 'why', 'are', and 'we' will give back 'whyarewe' through text(). The rest of wrap will proceed to treat that as one word, naturally.
This becomes an issue when wrap() is called multiple times on text elements that have already been processed by wrap().