I want to add html to a rectangle in D3 to give me a tooltip with multiple lines. The bottom is how I add the rectangle, which may be part of the problem. The top is the code that should work in my world.
newRect.().html(" <textArea font-family=Verdana font-size=20 fill=blue > Test " + "</br>" + "Test2 </textArea>");
What inserts a text field into SVG, it just doesn't appear:
HTML
<rect id="rectLabel" x="490" y="674" width="130" height="160" fill="red"> <textarea fill="blue" font-size="20" font-family="Verdana"> Test </br>Test2 </textarea> </rect>
I have a mouse function that runs the following:
newRect = svg.append("rect") .attr("x", xCor) .attr("y", yCor) .attr("width", 130) .attr("height", 160) .attr("fill", "red") .attr("id", "rectLabel");
I think I should do it, but it wonβt work. It just removes the g.node I'm trying to add to.
newRect = $(this).enter().append("rect") .attr("x", xCor) .attr("y", yCor) .attr("width", 130) .attr("height", 160) .attr("fill", "red") .attr("id", "rectLabel");
Question: Why is my text not appearing? Ive tried .html, .textArea. I want a multi-line shortcut, so I don't think .text will work correctly? Also, how should I add a rectangle?
gbam Dec 17 '13 at 20:51 2013-12-17 20:51
source share