d3.js中不同字段的悬停功能

时间:2018-09-21 17:13:23

标签: d3.js

我想为d3.js中的不同字段获取不同的悬停名称,我尝试使用以下代码。它仅在所有四个字段中都给出了“员工城市”。有人可以帮忙吗? 预先感谢。

// Enter any new nodes at the parents previous position.
                        var nodeEnter = node.enter().append("g")
                            .attr("class", "node")
                            .attr("marker-end", "url(#arrowhead)")
                            .attr("transform", function(d) {
                                return "translate(" + source.x0 + "," + source.y0 + ")";
                            })
                            .on("click", nodeclick)

    nodeEnter.append("g:title")
    .text(function(d){
        if(d.Title)
        return ("Employee Title");
           if(d.City)
                  return ("Employee City");
              if(d.JobGrade)
                  return ("Employee Job Grade");
         if(d.count)
                  return ("Employee Count");

                });

0 个答案:

没有答案