I'm exporting the nodes and links to a json object like this, in order to write it to disk later. This is the data as I load it:
{
"nodes": [
{
"id": "a1",
"type": "activity",
"loaded": true,
"style": {"label": "Testing ZoomCharts"}
},
{
"id": "o1",
"type": "organization",
"loaded": true,
"style": {"label": "Ophileon"}
}
],
"links": [{
"id": "l1",
"from": "o1",
"to": "a1",
"style": {"label": "Executes"}
}
}
When I get the nodes and links from the current graph, like this
function exportNodes(){
var nodesandlinks = {"nodes":[],"links":[]};
nodesandlinks.nodes.push(chart._scene.data.nodes);
nodesandlinks.links.push(chart._scene.data.links);
alert(JSON.stringify(nodesandlinks));
}
It returns a result that I need to process again in order to reload it, since it has each node as an attribute.
{
"nodes": [{
"a1": {
"id": "a1",
"type": "activity",
"loaded": true,
"style": {"label": "Testing ZoomCharts"}
},
"o1": {
"id": "o1",
"type": "organization",
"loaded": true,
"style": {"label": "Ophileon"}
}
}],
"links": [{"l1": {
"id": "l1",
"from": "o1",
"to": "a1",
"style": {"label": "Executes"}
}}]
}
Is there another way to retrieve the nodes? I tried this already:
chart.data.nodes
TypeError: Cannot read property 'nodes' of undefined
chart.nodes
function (){return this._impl.scene.nodes()}
There is now a dedicated API function for exporting data from network chart:
var exportedData = chart.exportData(visibleOnly);
alert(JSON.stringify(exportedData));
See https://zoomcharts.com/developers/en/net-chart/api-reference/api/#NetChart.exportData