D3.js 将choropleth datamaps调整为datamaps中的容器

D3.js 将choropleth datamaps调整为datamaps中的容器,d3.js,datamaps,D3.js,Datamaps,我正在尝试创建一个dashbord,我使用了从中获得的choropleth数据映射 我的问题是,当我试图调整datamap图的大小以适合我的容器时,它没有得到正确的缩放 那么,如何将地图缩放到 width=100% and height = 450px. 希望您能在这里帮助我使用d3获取容器的大小: var containerw = d3.select(".containerclass").style("width'); var containerh = d3.select(".contain

我正在尝试创建一个dashbord,我使用了从中获得的choropleth数据映射

我的问题是,当我试图调整datamap图的大小以适合我的容器时,它没有得到正确的缩放

那么,如何将地图缩放到

width=100% and height = 450px.

希望您能在这里帮助我

使用d3获取容器的大小:

var containerw = d3.select(".containerclass").style("width');
var containerh = d3.select(".containerclass").style("height');
现在在svg上使用这些值:

var map = d3.select('.containerclass').append("svg").attr('class','map');

map.style('width',parseInt(containerw) + 'px').style('height',parseInt(containerh) + 'px');

你能把这个放在fiddle.R用户JS初学者这里--我应该把这个代码放在
的什么地方?正如上面提到的另一位用户,如果能在
jsfiddle
上看到这个答案,那就太好了。非常感谢。