I'm drawing a scatterplot with d3.js. With the help of this question :
Get the size of the screen, current web page and browser window
我用的是这个答案:
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
因此,我能够将我的绘图与用户窗口相匹配,如下所示:
var svg = d3.select("body").append("svg")
.attr("width", x)
.attr("height", y)
.append("g");
现在,当用户调整窗口大小时,我希望有一些东西能够调整绘图的大小.
PS:我的代码中没有使用jQuery.