How To Remove D3 Link Text From Visualization
When nodes within my force directed visualization are clicked any child nodes (and their associated links) are toggled on/off. However, the text which acts as a label for these lin
Solution 1:
It turns out no g
element with class link-text
ever gets created, so the exit selection is empty.
Replace
linkText.enter()
.append('text')
.append('textPath')
.attr('xlink:href', function(d) {
return'#text-path-' + d.target.id;
});
with
linkText.enter()
.append('g')
.attr('class', 'link-text')
.append('text')
.append('textPath')
.attr('xlink:href', function(d) {
return'#text-path-' + d.target.id;
});
Also, it's necessary to specify the identifier function for linkText
just like you did for path
, otherwise d3 cannot match the missing data with an exit selection!
var linkText = vis.selectAll('g.link-text').data(
links,
function (d) { return d.target.id; }
);
Post a Comment for "How To Remove D3 Link Text From Visualization"