为多级树实现d3-2way-tree

时间:2015-08-19 12:23:35

标签: javascript jquery d3.js

我指的是d3小部件d3 2 way tree。我希望树在顶部和底部进一步增长,我无法为它形成json数据。

1 个答案:

答案 0 :(得分:1)

在遵循JSON的过程中,我向父节点添加了两个节点,向子节点添加了两个节点:

{
    "name": "Airlines",
    "parents": [
        {
            "name": "Aviation",
            "isparent": true
        },
        {
            "name": "Transparent_companies",
            "isparent": true
        },
        {
            "name": "Transport_operators",
            "isparent": true,
            "parents": [
                { 
                    "name" : "parent-foo1",
                    "isparent" : true
                },
                { 
                    "name" : "parent-foo2",
                    "isparent" : true
                }
            ]
        }
    ],
    "children": [
        {
            "name": "Airline_alliances",
            "isparent": false
        },
        {
            "name": "Airlines_by_continent",
            "isparent": false
        },
        {
            "name": "Airlines_by_type",
            "isparent": false,
            "children": [
                { 
                    "name" : "children-foo1",
                    "isparent" : false
                },
                { 
                    "name" : "children-foo2",
                    "isparent" : true
                }
            ]
        },
        {
            "name": "Defunct_airlines",
            "isparent": false
        }
    ]
}