分区
¥Partition
示例 · 分区布局生成邻接图:节点链接树形图 的空间填充变体。节点并非在层级结构中绘制父子节点之间的连接,而是绘制为实心区域(圆弧或矩形),它们相对于其他节点的位置揭示了它们在层级结构中的位置。节点的大小编码了一个定量维度,这在节点链接图中很难显示。
¥Examples · The partition layout produces adjacency diagrams: a space-filling variant of a node-link tree diagram. Rather than drawing a link between parent and child in the hierarchy, nodes are drawn as solid areas (either arcs or rectangles), and their placement relative to other nodes reveals their position in the hierarchy. The size of the nodes encodes a quantitative dimension that would be difficult to show in a node-link diagram.
partition()
源代码 · 使用默认设置创建一个新的分区布局。
¥Source · Creates a new partition layout with the default settings.
partition(root) {#_partition}
源代码 · 布局指定的根 hierarchy,并在根及其后代上分配以下属性:
¥Source · Lays out the specified root hierarchy, assigning the following properties on root and its descendants:
node.x0 - 矩形的左边界
¥node.x0 - the left edge of the rectangle
node.y0 - 矩形的上边缘
¥node.y0 - the top edge of the rectangle
node.x1 - 矩形的右边缘
¥node.x1 - the right edge of the rectangle
node.y1 - 矩形的底边
¥node.y1 - the bottom edge of the rectangle
在将层次结构传递给分区布局之前,必须调用 root.sum。你可能还需要在计算布局之前调用 root.sort 来对层次结构进行排序。
¥You must call root.sum before passing the hierarchy to the partition layout. You probably also want to call root.sort to order the hierarchy before computing the layout.
partition.size(size) {#partition_size}
源代码 · 如果指定了 size,则将此树形布局的节点大小设置为指定的 [width, height] 双元素数组,并返回此树形布局。如果未指定 size,则返回当前大小,默认为 [1, 1]。
¥Source · If size is specified, sets this partition layout’s size to the specified two-element array of numbers [width, height] and returns this partition layout. If size is not specified, returns the current size, which defaults to [1, 1].
partition.round(round) {#partition_round}
源代码 · 如果指定了 round ,则根据给定的布尔值启用或禁用舍入,并返回此树形图布局。如果未指定 round,则返回当前的舍入状态,默认为 false。
¥Source · If round is specified, enables or disables rounding according to the given boolean and returns this partition layout. If round is not specified, returns the current rounding state, which defaults to false.
partition.padding(padding) {#partition_padding}
源代码 · 如果指定了 padding,则将 padding 设置为指定的数字,并返回此分区布局。如果未指定 padding,则返回当前 padding,默认为零。填充用于分隔节点的相邻子节点。
¥Source · If padding is specified, sets the padding to the specified number and returns this partition layout. If padding is not specified, returns the current padding, which defaults to zero. The padding is used to separate a node’s adjacent children.