Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to remove the clusters after re-set the nodes? #383

Open
ding-kai opened this issue Dec 20, 2019 · 2 comments
Open

how to remove the clusters after re-set the nodes? #383

ding-kai opened this issue Dec 20, 2019 · 2 comments

Comments

@ding-kai
Copy link

I removed all nodes before I set new nodes, but the cluster is still there, any method to remove it?
A temporary solution:
container.select('g.output').selectAll('.clusters').remove();

@xanterx
Copy link

xanterx commented Jul 30, 2020

Removing only clusters was causing it to overlap on the nodes, so I just cleared all the elements in order as they are rendered to fix that.

.selectAll('.clusters').remove();
.selectAll('.nodes').remove();
.selectAll('.edgePaths').remove();
.selectAll('.edgeLabels').remove();

@vquilon
Copy link

vquilon commented Oct 3, 2022

I found a maintained fork https://github.com/tbo47/dagre-es

If you search on the source code of that fork, the create_clusters.js, has the answer of why the clusters are not being removed, is because are not merged the enter selection of D3 clusters, with the exit selection of D3. I mentioned that because the merge between the enter and exit selection is the pattern that D3 uses to know which cluster has to be removed and which clusters enter or keep in the graph.

Just take a look at this repository, build it, because has support to D3 V7 with ES6 modules, and it has support for typescript too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants