0
데이터 시각화를 위해 dagre d3을 사용하고 있으며, 주문형 다이어그램을 만들었으며 가장자리를 설정해야했습니다. 내가 갇혀있는이 코드 조각을 보아라dagre d3 부모로부터 모든 자식까지 모서리를 만듭니다.
/*data has this template
level: type: label
f.e.: 0: call: label1 //child of root
1: call: label2 //is child of 0
2: call: label3 //is child of 1
2: exit: label4 //is child of 1
1: exit: label5 //is child of 0, does not have children
0: exit: label6 //is child of root, does not have children
*/
function makeGraph(data){
//parsing data here, object from it looks like below saving to array named 'states'
//object = { id: id, level: par[1], type: par[2], label: par[3] };
var g = new dagreD3.graphlib.Graph().setGraph({});
g.setNode("root", { label: " ", style: "fill: #AAAAAA" }); //root node
states.forEach(function (state) {
g.setNode(state.id, { label: state.label, style: "fill: " + state.color });
if (state.level == 0) {
g.setEdge("root", state.id, { label: state.type });
} else {
//I can't find out how to set edges to parent here
}
});
//continuation of function with rendering
}
도표는 주문되었고, 루트가 위에있다. 루트 노드에서 나는 루트에서 레벨 0의 모든 노드로 가장자리를 만들 수있었습니다. 이제 레벨이 0이고 자식이 있고 그 다음 레벨이 1이고 자식이있는 모든 가장자리에서 가장자리를 만들고 싶습니다. 나는 이미 비슷한 것을 시도해 보았고 C#의 json에이 구조체를 저장했다. 그러나 javascript 놈이므로 javascript에 C# 코드를 다시 작성할 수는 없다.