여기에 표시된대로 d3 맵에 흐림 효과를 사용하고 있습니까? http://geoexamples.blogspot.in/2014/01/d3-map-styling-tutorial-ii-giving-style.html?d3 map - 흐림 필터를 사용한 후 줌이 제대로 작동하지 않습니다.
그러나이 방법을 사용한 후에 (데이터가로드되고 사용되는 데이터 때문에) 줌 기능이 무작위로 작동합니다. 클릭 한 위치와 관계없이 동일한 지점을 확대/축소합니다. 또한 필터를 사용하면 애니메이션이 매우 느려집니다.
흐림 효과를 얻는 다른 방법이 있습니까? 또는이 문제에 대한 해결책은 무엇입니까?
어떤 도움이 필요합니까?
감사합니다. 필터링이 필요한 경우 (위 사이트의 코드에 따라 데이텀 사용) 세계 제작을위한 코드입니다.
d3.json("world-110m2.json", function(error, world) {
g.insert("path")
.datum(topojson.feature(world, world.objects.land))
.attr("d", path);
g.insert("path")
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
.attr("d", path)
.append("path");
g.selectAll("path")
.on("click", click);})
이
가 필요하지 않습니다 경우 필터링에 사용되는 코드 (자료 없음 사용 - 어쩌면 데이텀이 문제를 일으키는)입니다d3.json("world-110m2.json", function(error,topology) {
g.selectAll("path")
.data(topojson.object(topology, topology.objects.countries)
.geometries)
.enter()
.append("path")
.attr("d",path)
.on("click", click);)}
이 줌 기능은 다음과 같습니다 여기에서 코드를 가지고 : http://bl.ocks.org/mbostock/2206590
function click(d) {
var x, y, k;
var centered;
if (d && centered !== d) {
var centroid = path.centroid(d);
x = centroid[0];
y = centroid[1];
k = 4;
centered = d;
} else {
x = width/2;
y = height/2;
k = 1;
centered = null;
}
if (active === d) return reset();
g.selectAll(".active").classed("active", false);
d3.select(this).classed("active", active = d);
var b = path.bounds(d);
g.selectAll("path")
.classed("active", centered && function(d) { return d === centered; });
g.transition()
.duration(750)
.attr("transform", "translate(" + width/2 + "," + height/2 + ")scale(" + k + ")translate(" + -x + "," + -y + ")")
.style("stroke-width", 1.5/k + "px");
}
전체 코드를 게시 할 수 있습니까? 확대/축소 동작이 필터와 다르게 동작해야하는 이유는 없습니다. –
코드를 업데이트했습니다. 필터링이 필요한 경우 데이텀 사용이 필요합니다. 심지어 내가 필터를 적용 해달라고하지 않을 때, 줌 does not는 잘 작동한다. 어떻게 든 데이터를 사용하는 방법과 관련이 있습니다. – user2426035
동일한 것을 수행하지만 사용 된 문맥을 알려주지 않은 두 개의 코드를 게시했습니다. 줌 기능을 보는 것도 도움이됩니다. –