GoJS nodeArrayData

Hi, can someone help me to solve this problems ?
I have used goJS to create flowchart and the json data default look like below:

nodeDataArray: [
{ key: ‘Alpha’, label: ‘Alpha’, color: ‘lightblue’ },
{ key: ‘Beta’, label: ‘Beta’, color: ‘orange’ },
{ key: ‘Gamma’, label: ‘Gamma’, color: ‘lightgreen’ },
],
linkDataArray: [
{ from: ‘Alpha’, to: ‘Beta’, text: ‘Yes123’ },
{ from: ‘Alpha’, to: ‘Gamma’, text: ‘Yes123’ },
],

But if i want to format nested data in nodeDataArray look like below:

nodeDataArray: [
        { key: 'Alpha', label: 'Alpha', color: 'lightblue', data:[
            {
            key:'Alpha child',
            label:'Alpha child',
            color:'red';
            data:[{key:'', label:'', color:''}]
            },{
             key:'Alpha child',
            label:'Alpha child',
            color:'red';
            },
        ] },
        { key: 'Beta', label: 'Beta', color: 'orange' },
      ],

So could we can do it? Thanks for help!

I hope it is a typo that you have duplicate key values.

The Model.nodeDataArray must be an Array and the Diagram will create exactly one Node per item. But you could copy your data structure and flatten it. I thought we had a sample that does that, but I cannot find it just now.

1 Like