我最近迁移到了D3 v4.10.2。根据文档的指示,我调用了缩放行为,但是当使用鼠标滚轮或触摸屏进行缩放时,回调没有被执行。我正在使用最新版本的Chrome浏览器:
var some_svg = d3.select('body').select("#some-svg");
var some_svg_rect = some_svg.append("g").append("rect")
.attr("fill","none")
.attr("width",900)
.attr("height",400);
some_svg_rect.call(d3.zoom()
.on("zoom", function () {/*this code fails to execute*/}));
感谢您设置“pointer-events”为“all”,缩放功能已经可以正常使用了。但是拖动行为只在开始拖动时起作用,是否有什么遗漏?
some_svg_rect.call(d3.drag()
.on("start", function () {/*this code works*/})
.on("drag", function () {/*this code fails toexecute*/})
.on("end", function () {/*this code fails to execute*/}));