D3 Typeerror: Link.exit Is Not A Function Link.exit().remove(); What Am I Doing Wrong?
I'm making a D3 tree layout. I've looked all over and it seems like this error shows up when you don't have data tied to the DOM and you try to remove it. I've ensured not only tha
Solution 1:
Notice what link
is getting assigned to:
link = linkElements.selectAll("path.link")
.data(links)
.enter() // <----- THIS
.append("path")
.attr("class", "link")
.attr("d", diagonal);
So link
is a selection containing newly appended nodes resulting from the enter()
sub-selection, so it doesn't have an exit()
sub-selection by definition.
What you need (and probably meant) to do is assign link
to the entire data-bound selection, and then work on the sub-selections:
link = linkElements.selectAll("path.link")
.data(links);//link assigned
link.enter() // <----- THIS
.append("path")
.attr("class", "link")
.attr("d", diagonal);
link.exit().remove(); //no more errors!
Post a Comment for "D3 Typeerror: Link.exit Is Not A Function Link.exit().remove(); What Am I Doing Wrong?"