我正在寻找一种方法,使用d3.js在工具提示文本元素中使用换行符.
.text("test" + "</br>" + "test")
Run Code Online (Sandbox Code Playgroud)
上述和其他类似的努力似乎不起作用.
这里有一个线程似乎回答了它:
https://groups.google.com/forum/?fromgroups=#!topic/d3-js/GgFTf24ltjc
但解决方案不是很清楚.在上述情况下如何使用.html?
.text(.html("test"+""+"test"))
没用?
谢谢
lsu*_*guy 16
由于您已经知道要打破文本的位置,因此可以考虑添加单独的元素.
.append("text")
.attr("dy", "0em")
.text("line 1") // "line 1" or whatever value you want to add here.
Run Code Online (Sandbox Code Playgroud)
然后对于第二行,只需添加一个偏移量
.append("text")
.attr("dy", "1em") // you can vary how far apart it shows up
.text("line 2") // "line 2" or whatever value you want to add here.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44348 次 |
| 最近记录: |