我将节点和链接导出到这样的json对象,以便稍后将其写入磁盘。这是我加载它时的数据:
{
"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"}
}
}当我从当前图中得到节点和链接时,如下所示
function exportNodes(){
var nodesandlinks = {"nodes":[],"links":[]};
nodesandlinks.nodes.push(chart._scene.data.nodes);
nodesandlinks.links.push(chart._scene.data.links);
alert(JSON.stringify(nodesandlinks));
}它返回一个我需要再次处理的结果,以便重新加载它,因为它有每个节点作为属性。
{
"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"}
}}]
}还有其他方法来检索节点吗?我已经试过了:
chart.data.nodes
TypeError: Cannot read property 'nodes' of undefined
chart.nodes
function (){return this._impl.scene.nodes()} 发布于 2014-04-08 11:21:06
现在有一个专用的API函数,用于从网络图导出数据:
var exportedData = chart.exportData(visibleOnly);
alert(JSON.stringify(exportedData));请参阅https://zoomcharts.com/developers/en/net-chart/api-reference/api/#NetChart.exportData
发布于 2014-04-07 15:55:52
不如:
function exportNodes(){
var nodesandlinks = {"nodes":[],"links":[]};
for (var n in chart._scene.data.nodes){
nodesandlinks.nodes.push(chart._scene.data.nodes[n]);
}
for (var l in chart._scene.data.links){
nodesandlinks.links.push(chart._scene.data.links[l]);
}
alert(JSON.stringify(nodesandlinks));
}https://stackoverflow.com/questions/22913093
复制相似问题