简体   繁体   English

JIT添加子图单个边缘颜色

[英]JIT adding sub graph individual edge color

I'm having a radial graph showing two levels of nodes. 我有一个显示两个节点级别的径向图。 On clicking a node it is possible to add a sub graph with calling the sum() function. 单击节点时,可以通过调用sum()函数来添加子图。 Everything works fine except setting individual color for the newly added edges. 除了为新添加的边缘设置单独的颜色之外,其他所有功能都可以正常工作。 Does anybody have ever tried to load sub graphs with individual edge colors or have a hint what I'm doing wrong? 是否有人尝试用单独的边缘颜色加载子图,或者有暗示我做错了什么?

Here I'm getting and adding the sub graph: 在这里,我得到并添加了子图:

subtree = getSubtree(node.id);  

//perform animation.  
subtree.success(function(data){
    rg.op.sum(data, {  
        type: 'fade:seq',  
        fps: 40,  
        duration: 1000,  
        hideLabels: false,  
    });  
});

I've checked also the loaded data but for me it seems to be totally equal. 我也检查了加载的数据,但对我来说似乎是完全相等的。 I've also loaded the same data into the initial graph instead of the sub graph and then it was colored correct. 我也将相同的数据加载到初始图形中,而不是子图形中,然后将其着色为正确的颜色。 Nevertheless here is some test data which is the result of the function getSubtree (the id "placeholder" matches the id of the existing where the sub graph should be added): 尽管如此,这里还是一些测试数据,这些数据是功能getSubtree的结果(ID“占位符”与应在其中添加子图的现有ID匹配):

{
"id": "placeholder1",
"name": "country",
"children": [{
    "id": "2_3mSV~_scat_1",
    "name": "hyponym",
    "children": [{
        "children": [],
        "adjacencies": {
            "nodeTo": "2_3mSV~_scat_1",
            "data": {
                "$color": "#29A22D"
            }
        },
        "data": {
            "$color": "#29A22D"
        },
        "id": "3_58z3q_sc_174_6",
        "name": "location"
    }],
    "data": {
        "$type": "star",
        "$color": "#666666"
    },
    "adjacencies": [{
        "nodeTo": "3_58z3q_sc_174_6",
        "data": {
            "$color": "#29A22D"
        }
    }]
}]
}

I finally found the problem in the framework itself... 我终于在框架本身中发现了问题。

When calling the construct function inside the call of sum() which is actually adding the subtree then the data object containing information about the adjacence's individual visualization is not used for adding the new adjacence. 在实际上是在添加子树的sum()调用中调用构造函数时,包含有关邻接的单个可视化信息的数据对象不会用于添加新的邻接。 Therefore I changed the code manually (this for loop is the new version of the existing for loop inside the construct() function): 因此,我手动更改了代码(此for循环是Construct()函数中现有for循环的新版本):

for(var i=0, ch = json.children; i<ch.length; i++) {

  //CUSTOM CODE: GET DATA OF THIS ADJACENCE
      data = null;
      if(ch[i].adjacencies[0]==undefined){
      data = ch[i].adjacencies.data;
      }
      else{
          data = ch[i].adjacencies.data;
      }

      ans.addAdjacence(json, ch[i], data);
      arguments.callee(ans, ch[i]);
      //CUSTOM CODE END

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM