Попробуйте этот путь.
link.on('mouseover', function(d, i) {
d3.select(this).style("stroke", "red");
if (!d3.select("#link-label-" + i).node()) {
svg.append("text")
.attr("id", "link-label-" + i)
.attr("font-family", "Arial, Helvetica, sans-serif")
.attr("x", function() {
if (d.target.x > d.source.x) {
return (d.source.x + (d.target.x - d.source.x)/2);
} else {
return (d.target.x + (d.source.x - d.target.x)/2);
}
})
.attr("y", function() {
if (d.target.y > d.source.y) {
return (d.source.y + (d.target.y - d.source.y)/2);
} else {
return (d.target.y + (d.source.y - d.target.y)/2);
}
})
.attr("fill", "Black")
.style("font", "normal 12px Arial")
.attr("dy", ".35em")
.text(function() {
return d.source.name + " - " + d.target.name;
});
}
}).on('mouseout', function(d, i) {
d3.select(this).style("stroke", d.target.group == 2?"black":"#9ecae1");
d3.select("#link-label-" + i).remove();
});
Обновлено fiddle
http://jsfiddle.net/pria_3/70qy8ps6/6/ Ссылка на код –
link.on ("наведении курсора мыши", функция() {d3.select (это). style ("stroke", "red"). text ("hello");}); –
Вы должны включить ссылку на код в вопросе. – colidyre