有人能告诉我以下代码究竟发生了什么?我知道它用于缩放,但是在这个上下文中2-d边界数组的作用是什么?
var bounds = path.bounds(d),
dx = bounds[1][0] - bounds[0][0],
dy = bounds[1][1] - bounds[0][1],
x = (bounds[0][0] + bounds[1][0]) / 2,
y = (bounds[0][1] + bounds[1][1]) / 2,
scale = .9 / Math.max(dx / width, dy / height),
translate = [width / 2 - scale * x, height / 2 - scale * y];
Run Code Online (Sandbox Code Playgroud)
提前致谢.
d3.js ×1