I am trying to add a multi-line tooltip and have some problems, mainly with how Internet Explorer handles it. I can really make my html look right, but IE ignores line breaks in the tooltip and puts it all on one line. Here are some snippets I tried (not the exact code, my dev station is in a closed network, so please ignore the missing irrelevant information such as position, etc.)
var bars = svg.selectAll(".bar") .data(data) .enter().append("rect") .attr("class","bar") .append("title").text(function(d){ return "Line One X:" + dx + "\nLine Two Y:" + dy});
This seems like an almost better solution and displays HTML as
<title> Line One X: 25 Line Two Y: 30 </title>
Firefox treats this as just two lines, but IE ignores line breaks and puts them on one line. I have tried many options. If I use the title attribute of the rect element, FF makes it just fine, IE completely ignores it and does not display a tooltip. I even went so far as to get the title element under the direct to have tspans and br like this (removing the last added title above)
var barsTitle = bars.append("title"); barsTitle.append("tspan").text(function(d){ return "Line One X:" + dx}); barsTitle.append("br"); barsTitle.append("tspan").text(function(d){ return "Line Two Y:" + dy});
which does what I think is correct HTML
<title> <tspan>Line One X: 25</tspan> <br></br> <tspan>Line Two Y: 30</tspan> </title>
Here again, IE completely ignores br, even if I insert line 2 in br (between the br open and close tag) IE still ignores it. Is there a simple solution?
Joe
source share