EDITED ANSWER
Just noticed that you're working with a tspan here. Unfortunately you can't insert line breaks into svg text elements. Multiline text with SVG requires breaking up the text yourself and then laying it out by setting the dy
attribute. D3 makes the laying out process pretty straight forward, but it still takes extra work.
More info in the intro paragraph here: http://www.w3.org/TR/SVG/text.html
OLD ANSWER (applies if using html elements, not svg)
D3 has a separate method for this: the html()
method, which works just like text()
but unescaped. More info here. So, easily enough, you just need:
textEnter.append("tspan")
.attr("x", 0)
.html(function(d,i) {
return 'some text' + '<br/>' + d.someProp;
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…