Skip to content

集群

🌐 Cluster

/Chaos/Chaos/Eros/Chaos/Erebus/Chaos/Tartarus/Chaos/Gaia/Chaos/Gaia/Mountains/Chaos/Gaia/Pontus/Chaos/Gaia/UranusEros/Chaos/ErosErebus/Chaos/ErebusTartarus/Chaos/TartarusMountains/Chaos/Gaia/MountainsPontus/Chaos/Gaia/PontusUranus/Chaos/Gaia/UranusChaos/ChaosGaia/Chaos/Gaia

示例 · 聚类布局生成树状图:节点链接图,将树的叶节点放在相同深度。树状图通常比整洁树不那么紧凑,但在所有叶节点都应处于同一水平时非常有用,例如用于层次聚类或系统发育树图

cluster()

来源 · 使用默认设置创建一个新的集群布局。

集群()

🌐 cluster(root)

来源 · 列出指定的 root 层级,在 root 及其子代上分配以下属性:

  • node.x - 节点的 x 坐标
  • node.y - 节点的 y 坐标

坐标 xy 表示一个任意的坐标系统;例如,你可以将 x 视为角度,将 y 视为半径,以生成一个径向布局。在将层次结构传递给聚类布局之前,你可能需要调用 root.sort

🌐 The coordinates x and y represent an arbitrary coordinate system; for example, you can treat x as an angle and y as a radius to produce a radial layout. You may want to call root.sort before passing the hierarchy to the cluster layout.

cluster.size(size)

来源 · 如果指定了 size,则将此聚类布局的大小设置为指定的两个元素的数字数组 [width, height],并返回此聚类布局。如果未指定 size,则返回当前布局大小,默认值为 [1, 1]。布局大小为 null 表示将使用 节点大小。坐标 xy 代表任意坐标系统;例如,要生成 放射状布局,大小为 [360, radius] 对应宽度为 360°,深度为 radius

cluster.nodeSize(size)

来源 · 如果指定了size,则将此聚类布局的节点大小设置为指定的两个元素的数组[width, height],并返回此聚类布局。如果未指定size,则返回当前节点大小,默认值为null。节点大小为null表示将使用布局大小。当指定节点大小时,根节点始终定位在⟨0, 0⟩。

cluster.separation(separation)

来源 · 如果指定了 separation,则将分离访问器设置为指定的函数并返回该聚类布局。如果未指定 separation,则返回当前的分离访问器,默认为:

js
function separation(a, b) {
  return a.parent == b.parent ? 1 : 2;
}

分离访问器用于分离相邻的叶子节点。分离函数接受两个叶子节点 ab,并且必须返回所需的分离距离。节点通常是兄弟节点,尽管如果布局决定将这些节点放置在相邻位置,节点也可能关系较远。

🌐 The separation accessor is used to separate neighboring leaves. The separation function is passed two leaves a and b, and must return the desired separation. The nodes are typically siblings, though the nodes may be more distantly related if the layout decides to place such nodes adjacent.