後でディスクに書き込むために、ノードとリンクをこのような 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()}