the original data is tiled, such as
originalData: [
{ company: "AAA", department:"AAA-D1", office: "AAA-D1-O1", pass: 1, onhold: 3},
{ company: "AAA", department:"AAA-D1", office: "AAA-D1-O2", pass: 3, onhold: 5},
{ company: "AAA", department:"AAA-D2", office: "AAA-D2-O1", pass: 2, onhold: 7},
{ company: "BBB", department:"BBB-D1", office: "BBB-D1-O1", pass: 1, onhold: 3},
{ company: "BBB", department:"BBB-D2", office: "BBB-D2-O1", pass: 4, onhold: 3},
{ company: "BBB", department:"BBB-D3", office: "BBB-D3-O1", pass: 1, onhold: 3},
....
....
]
want to convert to
treeData: [
{ label: "AAA", department:"AAA-D1", office: "AAA-D1-O1", pass: 6, onhold: 15, // company level
children: [ // department level
{label: "AAA-D1", pass: 4, onhold: 8,
children: [ // office level
{label: "AAA-D1-O1", pass: 1, onhold: 3},
{label: "AAA-D1-O2", pass: 1, onhold: 3},
]
},
{label: "AAA-D2", pass: 2, onhold: 7,
children: [
{label: "AAA-D2-O1", pass: 1, onhold: 3},
]
},
]
},
...
...
]
convert the data into parent-child structure according to the specified column, for example, the above is based on ["company"," department", "office"]. I don"t know how to write it. Please guide: (: (
.