我正在用d3.js绘制散点图。带着这个问题的帮助:
Get the size of the screen, current web page and browser window在d3.js中调整窗口大小时调整svg的大小
我用这样的回答:
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。
可能的重复[什么是使d3.js可视化布局响应的最佳方式?](http://stackoverflow.com/questions/9400615/whats-the-best-way-to-make-a-d3-js -visualisation-layout-responsive) – ColinE 2016-06-26 18:01:21