문제

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. 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):

{
"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. Therefore I changed the code manually (this for loop is the new version of the existing for loop inside the construct() function):

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 ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top