我使用dTree.js创建了一个家谱图,但我怎么能只创建一个母亲与父亲结婚

时间:2017-07-13 07:53:31

标签: javascript json family-tree

look my picture

这张照片是我用dTree.js创建的一个家谱图表;有两个母亲;但这不是我想要的;

这是我的代码

[
{
    "name": "granddad",
    "class": "man",
    "textClass": "emphasis",
    "marriages": [
        {
            "spouse": {
                "name": "grandmother",
                "class": "woman"
            },
            "children": [
                {
                    "name": "aunt",
                    "class": "woman"
                },
                {
                    "name": "uncle",
                    "class": "man"
                },
                {
                    "name": "father",
                    "class": "man",
                    "marriages": [
                        {
                            "spouse": {
                                "name": "mother",
                                "class": "woman",
                                "id": 3
                            },
                            "children": [
                                {
                                    "name": "sister",
                                    "class": "woman"
                                },
                                {
                                    "name": "me",
                                    "class": "man"
                                },
                                {
                                    "name": "brother",
                                    "class": "man",
                                    "hidden": true
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
},
{
    "name": "grandfather",
    "class": "man",
    "textClass": "emphasis",
    "marriages": [
        {
            "spouse": {
                "name": "grandmother",
                "class": "woman"
            },
            "children": [
                {
                    "name": "mother",
                    "class": "woman",
                    "id": "3"
                },
                {
                    "name": "aunt",
                    "class": "woman"
                }
            ]
        }
    ]
}

<script>

var data_json = '/admin/test/json';

treeJson = d3.json(data_json, function (error, treeData) {
    dTree.init(treeData, {
        target: "#graph",
        debug: true,
        height: 800,
        width: 1200,
        callbacks: {
            nodeClick: function (name, extra) {
                console.log(name);
            }
        }
    });
});

我想创建一个这样的图表:只有一位母亲与父亲结婚;

https://i.stack.imgur.com/db8I3.jpg

我该怎么办?

0 个答案:

没有答案