弦
🌐 Chords
弦布局计算角度以生成 弦图。
🌐 The chord layout computes angles to generate a chord diagram.
和弦()
🌐 chord()
来源 · 使用默认设置构建一个新的和弦布局。
const chord = d3.chord();和弦(矩阵)
🌐 chord(matrix)
来源 · 计算指定的大小为 n×n 的方形 矩阵 的和弦布局,其中该 矩阵 表示 n 个节点的网络(一个完全有向图)之间的有向流。
chord(matrix) 的返回值是一个 chords 数组,其中每个 chord 表示两个节点 i 和 j(其中 i 可能等于 j)之间的双向流量总和,并且是具有以下属性的对象:
🌐 The return value of chord(matrix) is an array of chords, where each chord represents the combined bidirectional flow between two nodes i and j (where i may be equal to j) and is an object with the following properties:
source- 源子组target- 目标子组
每个源子组和目标子组也是一个具有以下属性的对象:
🌐 Each source and target subgroup is also an object with the following properties:
startAngle- 起始角度(弧度)endAngle- 以弧度为单位的结束角度value- 流量值 矩阵[我][j]index- 节点索引 i
这些和弦通常会被传递给 ribbon 来显示网络关系。
🌐 The chords are typically passed to ribbon to display the network relationships.
返回的数组仅包括那些其值 matrix[我][j] 或 matrix[j][i] 非零的和弦对象。此外,返回的数组只包含唯一的和弦:给定的和弦 ij 表示从 i 到 j 以及从 j 到 i 的双向流动,并且不包含重复的和弦 ji;i 和 j 的选择是使和弦的源始终表示 matrix[我][j] 和 matrix[j][i] 中较大的值。
🌐 The returned array includes only chord objects for which the value matrix[i][j] or matrix[j][i] is non-zero. Furthermore, the returned array only contains unique chords: a given chord ij represents the bidirectional flow from i to j and from j to i, and does not contain a duplicate chord ji; i and j are chosen such that the chord’s source always represents the larger of matrix[i][j] and matrix[j][i].
chords 数组还定义了一个长度为 n 的二级数组 chords.groups,其中每个组表示节点 i 的合并流出,对应于元素 matrix[我][0 … n - 1],并且是具有以下属性的对象:
🌐 The chords array also defines a secondary array of length n, chords.groups, where each group represents the combined outflow for node i, corresponding to the elements matrix[i][0 … n - 1], and is an object with the following properties:
startAngle- 起始角度(弧度)endAngle- 以弧度为单位的结束角度value- 节点i的总流出值index- 节点索引 i
这些组通常被传递给 arc,以在弦布局的周长上生成一个环形图。
🌐 The groups are typically passed to arc to produce a donut chart around the circumference of the chord layout.
chord.padAngle(angle)
来源 · 如果指定了angle,则设置相邻组之间的垫角为指定的弧度数,并返回此弦布局。如果未指定angle,则返回当前的垫角,默认值为零。
chord.sortGroups(compare)
来源 · 如果指定了 compare,则将组比较器设置为指定的函数或 null,并返回此弦图布局。如果未指定 compare,则返回当前的组比较器,默认值为 null。如果组比较器非空,则用于按组的总流出量对组进行排序。另请参见 ascending 和 descending。
chord.sortSubgroups(compare)
来源 · 如果指定了 compare,则将子组比较器设置为指定的函数或 null,并返回此和弦布局。如果未指定 compare,则返回当前的子组比较器,默认为 null。如果子组比较器非 null,则它用于按给定组 i 对应的 matrix[我][0 … n - 1] 的子组的总流出排序。另请参见 升序 和 降序。
chord.sortChords(compare)
来源 · 如果指定了 compare,则将和弦比较器设置为指定的函数或 null,并返回此和弦布局。如果未指定 compare,则返回当前的和弦比较器,默认为 null。如果和弦比较器非 null,它将用于按和弦的组合流排序 chords;这只影响和弦的 z 顺序。另请参见 ascending 和 descending。
chordDirected()
示例 · 来源 · 用于单向流的和弦布局。从 i 到 j 的和弦仅由 matrix[我][j] 中的值生成。
chordTranspose()
来源 · 一个转置的和弦布局。用于强调流出(而不是流入)的流动。