你可以在使用d3.js时在文本中插入换行符吗? [英] Can you insert a line break in text when using d3.js?

查看:292
本文介绍了你可以在使用d3.js时在文本中插入换行符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用d3.js在工具提示文本元素中使用换行符的方法。

 。文本(test+< / br>+test)



<和其他类似的努力,似乎不工作。



这里有一个线程似乎回答:



https://groups.google.com/forum/ ?fromgroups =#!topic / d3-js / GgFTf24ltjc



但解决方案不是很清楚。 .html在上述情况下如何使用?



.text(.html(test++test))

$ b

解决方案

div>

这意味着用.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆