📅  最后修改于: 2022-03-11 14:59:53.294000             🧑  作者: Mango
let zoom = d3.zoom().on("zoom", zoomed);
let svg = d3.select("svg")
.attr("width", "100%")
.attr("height", "100%")
.style("background-color", "#eeeeee")
.call(zoom)
.on("dblclick.zoom", null);
let g = svg.append("g");
//d3.selectAll("#zoom-section i").on("click", zoomClick);
g.append("circle").attr("r", 50).attr("fill", "red");
d3.select("#zoom_in").on("click", function() {
zoom.scaleBy(svg.transition().duration(750), 1.2);
});
d3.select("#zoom_out").on("click", function() {
zoom.scaleBy(svg.transition().duration(750), 0.8);
});
function zoomed() {
g.attr("transform", d3.event.transform);
}