Clustering with forceRadial
MaksZhukov opened this issue · 2 comments
MaksZhukov commented
Can I set up clustering behavior for some nodes with help forceRadial for different positions?
I see I can set x,y,z
as value, not a callback for each node.
If I can't, could you give me the best solutions to see some group of nodes around a group of x,y,z
positions?
vasturiano commented
@MaksZhukov the x
, y
and z
methods do not support node accessor functions, only constant values. This is done to maintain consistency with d3-force.
What I would do is have multiple forceRadial
forces in your system, one for each cluster with preset x,y,z focal points. To make sure each force only applies to nodes in that cluster, you can set 0 strength
conditionally, like:
clusterNForce = forceRadial(10, ...clusterCoords)
.strength(node => isInCluster(node) ? 0.1 : 0)
MaksZhukov commented
@vasturiano Thank you!