2
我想利用D3的缩放行为功能,但我需要使用viewBox属性而不是transform方法对SVG进行所有转换/缩放,如D3例子:http://bl.ocks.org/mbostock/3680999如何在ViewBox中使用D3缩放行为而不是转换
我怎样才能达到这个规模/只使用viewBox翻译?这是我的代码到目前为止,这不像变换方法。
function zoomed(d) {
if (!scope.drawLine) {
var scale = d3.event.scale;
var translation = d3.event.translate;
//This works, but I can't use it for reason's I won't go into now
//mapSVG_G.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
var newViewBox = [
initialViewBox[0] - translation[0],
initialViewBox[1] - translation[1],
initialViewBox[2]/scale,
initialViewBox[3]/scale
];
mapSVG.attr('viewBox', newViewBox);
}
}
不幸的是,此解决方案的翻译功能不正确。 – Doughy