vis-network icon indicating copy to clipboard operation
vis-network copied to clipboard

closeCluster() ?

Open grekier opened this issue 6 years ago • 3 comments

Hi.

First thanks for the great lib. Loving it.

I was wondering if there was a possibility to close a cluster onClick? As of now, we use the openCluster to "expand" it but it would be nice to "revert" the change in some way.

Is it possible? If so, how? If not, could we add a feature request for it?

Thanks.

grekier avatar Jan 14 '20 13:01 grekier

Hi @grekier,

the naming here is a bit confusing. The method .cluster() creates a cluster and .openCluster() releases the clustered nodes and edges from the cluster and then disposes of it. There's no way to close it because it no longer exists.

To achieve what you want you can save the ids of the clustered nodes before calling .openCluster() and then use joinCondition in .cluster() to recreate the cluster with the same nodes.

Thomaash avatar Jan 14 '20 16:01 Thomaash

Thanks @Thomaash I tried what you suggested and recreated the cluster based on the id from the click event and it works nicely.

grekier avatar Jan 15 '20 07:01 grekier

You're welcome.

Thomaash avatar Jan 15 '20 09:01 Thomaash