如何使增量添加的节点在手动导航中持久化



使用zoomcharts(1.5.1)的NetChart,似乎addData()只适用于navigation = showall。如果我尝试使用navigation = manual,它需要initialNodes

是否有一种方法initialNodes自动获得与现有的数据填充(增量添加)?我想这样做的原因是,我想首先使用navigation = showall加载一组特定的节点/链接,然后将其更改为navigation = manual,以便用户可以点击查看所有邻居

基本上,下面的例子展示了这种情况…节点'f-1'被'm-1'的initialNodes覆盖。

<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>

找到了使用双击的解决方案:

<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>

相关内容

  • 没有找到相关文章

最新更新