^이 출생/사망/이름 데이터를 적용하려면 차트를 향상 시작하는 목표입니다 -하지만 그것을 가지고 더 유연성을 가지고가. 또한 데이터 소스를 정리합니다.
은 내가 d3.js 가족 차트를 개발하기 위해 노력하고 있습니다. 이 차트의 데이터 구조를 향상시키고 라벨에 공간/디자인을 추가하는 방법에 관심이 있습니다. 부품에 동적 길이를 부여하여 필요한 공간을 확보하는 방법이 있다면 관심이 있습니다.나는이 jsfiddle http://jsfiddle.net/857edt69/30/
// Create the node rectangles.
nodes.append("circle")
.attr("class", "node")
.attr("r", function(d, i) {
return smallRadius;
})
.style("fill", function(d, i) {
var userName = d.userName;
if (userName) {
userName.toLowerCase()
}
var id = d.id + "-" + userName; //small circles
return "url(#" + id + ")";
})
.attr("id", function(d) {
return d.id;
})
.attr("display", function(d) {
if (d.hidden) {
return "none"
} else {
return ""
};
})
.attr("cx", function(d) {
return d.x - (smallRadius/2) + 10;
})
.attr("cy", function(d) {
return d.y - (smallRadius/2) + 10;
});
// Create the node text label.
nodes.append("text")
.text(function(d) {
//return d.name;
return d.userName;
})
.attr("x", function(d) {
return d.x - (smallRadius/2) + 10;
})
.attr("y", function(d) {
return d.y - (smallRadius/2) - 20;
});
더 오래된 간단한 해결책 이 모두 당신이 그래프와 같은 및 graphlib과 호환 데이터 모델을 가지고 가정,하지만 당신은 쉽게 다시 graphlib에 데이터 구조를 변환 할 수 있습니다 - http://stackoverflow.com/questions/31245751/d3-js-family-tree-in-d3-js –