小编Hen*_*y S的帖子

无法在d3可折叠树中的链接上添加文本

在上面的代码我的.append("文本")dosent work.I没有在我的链接上插入任何文本.我尝试使用link.append("path")..使用此我可以看到文本但不能看到链接.我想使用link.insert("path"),仍然能够添加文本,并能够折叠和扩展节点以及链接文本.请帮忙

var link = svg.selectAll("path.link")
                         .data(links, function (d) { return d.target.id; });

// Enter any new links at the parent's previous position.
//  var link1=link.enter();
link.enter().insert("path", "g")
    .attr("class", "link")
    .attr("d", function (d) {
        var o = { x: source.x0, y: source.y0 };
        return diagonal({ source: o, target: o });
    });  

link.enter()
    .append("g")
    .attr("class", "link")
    .append("text")
    .attr("font-family", "Arial, Helvetica, sans-serif")
    .attr("fill", "Black")
    .style("font", "normal 12px Arial")
    .attr("transform", function(d) {
        return "translate(" +
        ((d.source.y + d.target.y)/2) + "," + 
        ((d.source.x + …
Run Code Online (Sandbox Code Playgroud)

d3.js

1
推荐指数
1
解决办法
1564
查看次数

标签 统计

d3.js ×1