我正在用d3.js绘制散点图。在这个问题的帮助下:
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");
现在,我希望当用户调整窗口大小时,会有一些东西负责调整绘图的大小。
附言:我没有在我的代码中使用jQuery。
https://stackoverflow.com/questions/16265123
复制相似问题