为多层树实现d3-2路树

Implementing d3-2way-tree for multilevel tree

本文关键字:d3-2 路树 实现      更新时间:2023-09-26

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

在以下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
        }
    ]
}