0
svg 태그와 d3 force 함수와 함께 사용하기위한 변수 링크에 노드를 추가하는 함수를 만들려고합니다.하지만 그렇게 할 수 없습니다.d3.js를 사용하여 함수를 대신 사용하여 코드를 추가하려면 어떻게해야합니까?
는이 코드가 있습니다
force
.nodes(graph.nodes)
.links(graph.links)
.start();
link = layer_graph.selectAll(".link")
.data(graph.links)
.enter()
.append("path")
.attr("stroke-width", 3)
.attr("d", "")
.on("mouseover", function(d) {
d3.select(this)
.classed("link_over", true);
})
.on("mouseout", function(d) {
d3.select(this)
.classed("link_over", false);
});
을 그리고 난 그런 식으로 뭔가를 변경하려면 :
force
.nodes(graph.nodes)
.links(graph.links)
.start();
layer_graph.selectAll(".link")
.data(graph.links)
.enter()
//It does not work (of course)
.call(function(d,i) {
something = something2.append("path")
.attr("stroke-width", 3)
.attr("d", "")
.on("mouseover", function(d) {
d3.select(this)
.classed("link_over", true);
})
.on("mouseout", function(d) {
d3.select(this)
.classed("link_over", false);
});
link.push(something);
});
나는 다른 방법을 시도하고있다 그리고 나는 해결책을 찾지 못했습니다.
당신이 뭘 하려는지 :
는 그리고 이건 내 구현? D3이 추가 된 요소 아래에 여러 요소를 그룹화 하시겠습니까? –
빠른 응답을 보내 주셔서 감사합니다 :). 음 "링크 생성"코드를 init 그래프와 ajax 호출에서 사용하기위한 함수로 그룹화하려고합니다. –
다른 방법으로 시도하고 있지만 ... 실행되고 있지 않습니다. http://pastebin.com/J5iuxRGV –