Reputation: 3166
Using the NetChart
of zoomcharts (1.5.1), it seems that addData()
only works for navigation = showall
. In case I try using navigation = manual
, it requires initialNodes
.
Is there a way initialNodes
automatically gets populated with existing data (that was added incrementally)? The reason I want that is because, I want to intially load a specific set of nodes/links using navigation = showall
and then change it to navigation = manual
so that user can click to see all neighbors
Basically, the following example shows this case... node 'f-1' is getting overwritten by initialNodes of 'm-1'.
<script>
var t = new NetChart({
container: document.getElementById("demo"),
area: { height: 350 }
});
t.addData({nodes: [{loaded: true,id: "f-1",name: "Anna"},{id: "m-1",name: "Joe"}],links: [{to: "f-1",from: "m-1",id: "l01",type: "friend"}]});
t.updateSettings({
data:
{
preloadNodeLinks:true,
dataFunction: function(nodeList, success, error){
//return just the first node, net chart will ask for more
jQuery.ajax({
url:"/dvsl/data/net-chart/friend-net/"+nodeList[0]+".json",
success: success,
error: error});
}
},
navigation:{
initialNodes:["m-1"],
mode:"manual"
}
});
</script>
Upvotes: 0
Views: 57
Reputation: 3166
Found a workaround by use of doubleclick:
<script>
var t = new NetChart({
container: document.getElementById("demo"),
area: {
height: 350
},
events:{
onDoubleClick: dclickEvent
}
});
t.addData({nodes: [{loaded: true,id: "f-1",name: "Anna"},{id: "m-1",name: "Joe"}],links: [{to: "f-1",from: "m-1",id: "l01",type: "friend"}]});
function dclickEvent(event){
if (!$("#click")[0].checked) return;
console.log('event.clickNode', event.clickNode);
if (event.clickNode) {
jQuery.ajax({
url: "/dvsl/data/net-chart/friend-net/" + event.clickNode.id + ".json",
success: function(data) {
console.log('test-foo-data', data);
t.addData(data);
}
})
}
}
</script>
Upvotes: 0