我正在用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