这是代码的链接:http://jsfiddle.net/mj58659094/ADXGu/ ;
现在家谱只有亲子之间的联系。我怎样才能获得配偶之间的链接,如下所示?
|-----------------------|
- - - | Father-3 (SMJ) |
- | |-
- |-----------------------| -
|-----------------------| - -
| Father-0 (PMI) |- |-----------------------| -
| |- | Mother-3 (AJ) | - -
|-----------------------| - | (AJ Nickname) |- -
- |-----------------------| -
|-----------------------| - -
| Mother-0 (MP) | - |-----------------------| -
| (AJ Nickname) |- | Mother-3 (MTJ) | -
|-----------------------| | (MTJNickname) |-
|-----------------------|
personId: "1000101"Father-3 (SMJ) 结过两次婚,第一任妻子是 personId: "1000102"Mother-3 (AJ),第二任妻子是 personId: "1000103"Mother-3 (MTJ)。任何帮助将不胜感激。谢谢。
最佳答案
您可以将配偶定位为父亲的 child (D3 不关心这一点),但由于您仅将 child 与父亲联系起来,因此配偶将出现在与 child 相同的级别:
Father 0 ---- Spouse 0-0
---- Spouse 0-1
---- Spouse 0-2
---- Father 1 ---- Spouse 1-0
---- Father 2
另一种解决方案可能是将 child 与配偶联系起来:
Father 0 ---- Spouse 0-0 ---- Father 1 ---- Spouse 1-0 ---- Father 2
---- Spouse 0-1
---- Spouse 0-2
我怀疑您需要一个不同的布局(例如 force layout)来表示 child 有两个 parent :
Spouse 0-2
|
|
Father 0 ---- Spouse 0-0
| \ /
| Father 1 ------ Father 2
| \ /
Spouse 0-1 Spouse 1-0
并且您可能想要区分 parent 对 child 的链接与丈夫和妻子的链接。
关于javascript - D3 : Links between spouses in a family tree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19296064/