我有一个径向图,显示了两个级别的节点。单击节点时,可以通过调用 sum() 函数添加子图。除了为新添加的边缘设置单独的颜色外,一切正常。有没有人尝试过加载具有单个边缘颜色的子图或暗示我做错了什么?
在这里,我正在获取并添加子图:
subtree = getSubtree(node.id);
//perform animation.
subtree.success(function(data){
rg.op.sum(data, {
type: 'fade:seq',
fps: 40,
duration: 1000,
hideLabels: false,
});
});
我还检查了加载的数据,但对我来说它似乎是完全平等的。我还将相同的数据加载到初始图形而不是子图形中,然后颜色正确。尽管如此,这里有一些测试数据,它是函数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"
}
}]
}]
}
我终于在框架本身中找到了问题......
当在 sum() 调用中调用构造函数时,该函数实际上是添加子树,则包含有关邻接的单个可视化信息的数据对象不用于添加新邻接。因此,我手动更改了代码(这个 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
}