(dataMap)
| 1 | export function dataMapToData(dataMap) { |
| 2 | const data = { nodes: [], edges: [], groups: [] }; |
| 3 | if (dataMap) { |
| 4 | Object.keys(dataMap).forEach((id) => { |
| 5 | const item = dataMap[id]; |
| 6 | if (item.type === 'node') { |
| 7 | data.nodes.push(item); |
| 8 | } else if (!!item.source && !!item.target) data.edges.push(item); |
| 9 | // just assuming that if an item is not node or edge but have x and y, it's a group |
| 10 | else if (!!item.x && !!item.y) { |
| 11 | data.groups.push(item); |
| 12 | } |
| 13 | }); |
| 14 | } |
| 15 | |
| 16 | return data; |
| 17 | } |