I'm searching for an elegant and efficient solution to transform my input data into a hierarchical structure using d3.js nest operator. Here is an example of the input data:
[
{id: 1, name: "Peter"},
{id: 2, name: "Paul", manager: 1},
{id: 3, name: "Mary", manager: 1},
{id: 4, name: "John", manager: 2},
{id: 5, name: "Jane", manager: 2}
]
What I aim to achieve is a hierarchy layout like the one shown below:
[
{name: "Peter", children: [
{name:"Paul", children: [
{name:"John"},
{name:"Jane"}
]},
{name:"Mary"}
]
}
]