vasturiano/d3-force-cluster-3d

Example Usage

Opened this issue · 4 comments

Issue

I'm trying to integrate d3-force-cluster-3d with d3-force-3d in a library I'm building. I hooked up the library and have it rendering but clustering is not working.

I think my problem is its not entirely clear what the centers method should return. I attempted https://github.com/reaviz/reagraph/blob/clusters/src/layout/forceDirected.ts#L62-L80 but it doesn't seem to be correct. I was wondering if you had an idea what I could be doing wrong or a better example I could lean on.

If you want, you can clone this branch https://github.com/reaviz/reagraph/tree/clusters and do yarn install + yarn start and goto Clustering storybook story that opens.

@amcdnl that accessor method should return the central coordinates of the cluster the node is associated to. Or you can choose a node in each cluster that represents the cluster center and just return that node object for the associated nodes.

I noticed that your force diagrams are in 2D. For that, ther regular d3-force-cluster module should suffice. Any specific reason why you prefer to use the 3d variant?

should return the central coordinates of the cluster the node is associated to

OK - Thats helpful. Is there a library you would recommend to calculate this?

Any specific reason why you prefer to use the 3d variant?

The library also supports 3D, I was just going to use this for both 2d and 3d. I assumed that would work if I just removed the Z dimension.

Is there a library you would recommend to calculate this?

Nothing comes to mind. A common pattern as I mentioned above is to simply use one of the nodes in the cluster as the cluster center. Assuming there are other forces active in the system, this way the cluster centers also keep moving and adjust to each other.

The library also supports 3D, I was just going to use this for both 2d and 3d. I assumed that would work if I just removed the Z dimension.

Ok. Yeah that should work fine. As long as the main force engine is configured with the matching number of dimensions, via numDimensions.

Thanks for your help - I got it working - you can see it here: https://reagraph.dev/?path=/story/demos-cluster--three-dimensions