나는 애니메이션을하는 D3의 트리 맵을 얻으려고 노력하고,이 답변에 따라루트 노드가 전달 될 때 d3 트리 맵 레이아웃이 캐시됩니까?
App.svg = d3.select("#medals-tree-map").append("svg:svg")
.style("width", App.canvasWidth)
.style("height", App.canvasHeight)
.append("svg:g")
.attr("transform", "translate(-.5,-.5)")
.attr("id", "container");
App.treemap = d3.layout.treemap()
.size([App.canvasWidth + 1, App.canvasHeight + 1])
.value(function(d) { return d.number; })
.sticky(true);
function drawGraphFromJson(data) {
// Draw the graph
var leaves = App.treemap(data);
var cell = App.svg.selectAll("g.cell")
.data(leaves);
// More rendering code
}
같은 있었다 : 내가 함께 drawGraphFromJson
를 호출 할 때 https://stackoverflow.com/a/9650825/111884
그러나, 트리 맵은 전혀 변경하지 않습니다 새로운 데이터.
나는function drawGraphFromJson(data) {
App.treemap = d3.layout.treemap()
.size([App.canvasWidth + 1, App.canvasHeight + 1])
.value(function(d) { return d.number; })
.sticky(true);
// Draw the graph
var leaves = App.treemap(data);
var cell = App.svg.selectAll("g.cell")
.data(leaves);
// More rendering code
}
왜 내가이 작업을 수행 할 필요가 수행
drawGraphFromJson
즉 내부
App.treemap
를 정의하여 문제를 해결? 루트 노드를 전달할 때
treemap
이 캐시됩니까?
아, 정확하게 'sticky' 플래그였습니다. 감사! Awesome framework btw =) – zlog
'sticky'를'true'에서'false'로 변경하면 같은 draw 노드의 위치도 변경 될 수 있습니까 (저는'.mode ("slice-dice")')를 사용하고 있습니까? –