d3-force-cluster-3d
v1.1.1
Published
A clustering force type for the d3-force-3d simulation engine.
Downloads
1,067
Maintainers
Readme
d3-force-cluster-3d
This is a 3D port of d3-force-cluster, a force type that attracts nodes toward a set of cluster centers.
This force plugin is compatible with d3-force-3d and can function in a one, two or three dimensional space.
Quick start
import d3ForceCluster from 'd3-force-cluster-3d';
or using a script tag
<script src="//unpkg.com/d3-force-cluster-3d"></script>
then
d3.forceSimulation()
.nodes(<myNodes>)
.force('cluster', d3.forceCluster()
.centers(node => clusters[node.cluster])
);
API reference
| Method | Description | Default |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------- |
| centers([fn]) | Getter/setter for the accessor function (fn(node)
) to define each node's cluster center. All cluster centers should be defined as a radius and set of coordinates { radius, x, y, z }
, according to the number of spatial dimensions in the simulation. | node => ({ x: 0, y: 0, z: 0 })
|
| strength([num]) | Getter/setter for the force strength. The value must be within the [0,1] range. This parameter determines the attraction strength of each node to the specified cluster center. | 0.1 |
| centerInertia([num]) | Getter/setter for the inertia of cluster center nodes. The value must be within the [0,1] range. Lower values (close to 0) result in cluster center nodes with lower inertia: they are easily pulled around by other nodes in the cluster. Higher values (close to 1) result in cluster center nodes that are moved very little by other nodes in the cluster. | 0 |