我想为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");
});