你可以在使用d3.js时在文本中插入换行符吗? [英] Can you insert a line break in text when using d3.js?
问题描述
我正在寻找一种使用d3.js在工具提示文本元素中使用换行符的方法。
。文本(test+< / br>+test)
<和其他类似的努力,似乎不工作。
这里有一个线程似乎回答:
https://groups.google.com/forum/ ?fromgroups =#!topic / d3-js / GgFTf24ltjc
但解决方案不是很清楚。 .html在上述情况下如何使用?
.text(.html(test++test))
$ b这意味着用.html()替换.text()
< br />+test)
应为
.html(test+< br />+test)
pre>
I'm looking for a way to use a line break within a tooltip text element using d3.js.
.text("test" + "</br>" + "test")
The above, and other similar efforts, don't seem to work.
There's a thread here that seems to answer it:
https://groups.google.com/forum/?fromgroups=#!topic/d3-js/GgFTf24ltjc
but the solution isn't very clear. How would .html be used in the above situation?
.text(.html("test" + "" + "test"))
didn't work?
Thanks
解决方案It means to replace .text() with .html()
.text("test" + "<br/>" + "test")
should be
.html("test" + "<br/>" + "test")
这篇关于你可以在使用d3.js时在文本中插入换行符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!