D3 Appending HTML to Nodes

后端 未结 1 1821
孤城傲影
孤城傲影 2021-02-01 20:03

I have looked for answer to this but none of the similar questions help me in my situation. I have a D3 tree that creates new nodes at runtime. I would like to add HTML (so I

相关标签:
1条回答
  • 2021-02-01 20:52

    Using Lars Kotthoff's excellent direction, I got it working so I decided to post it for others and my own reference:

    http://jsfiddle.net/FV4rL/2/

    with the following code appended:

    node.on("mouseover", function (d) {
                var g = d3.select(this); // The node
                var div = d3.select("body").append("div")
                        .attr('pointer-events', 'none')
                        .attr("class", "tooltip")
                        .style("opacity", 1)
                        .html("FIRST LINE <br> SECOND LINE")
                        .style("left", (d.x + 50 + "px"))
                        .style("top", (d.y +"px"));
    });
    
    0 讨论(0)
提交回复
热议问题