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
Since you already know where you want to break the text, you could consider just adding separate elements.
.append("text") .attr("dy", "0em") .text("line 1") // "line 1" or whatever value you want to add here.
And then for the second line, just add an offset
.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With