gpt4 book ai didi

javascript - 修改d3js中 map 的大小

转载 作者:行者123 更新时间:2023-11-30 16:02:41 31 4
gpt4 key购买 nike

http://www.datavis.fr/index.php?page=map-population 中提供的代码的帮助下,我使用 d3.js 制作了一张 map ,一切正常,但是我无法弄清楚如何调整 map 的大小,实际上我想让它变大但是当我尝试修改时:

var width = 600, height = 550;

它没有用,它只是让比例尺和 map 发生碰撞。

宽度和高度也出现在:

var projection = d3.geo.conicConformal()
.center([2.454071, 46.279229])
.scale(3000)
.translate([width / 2, height / 2]);

path.projection(projection);

var svg = d3.select('#'+id).append("svg")
.attr("id", "svg")
.attr("width", width)
.attr("height", height)
.attr("class", "Blues");

我假设这就是它不起作用的原因?谁能帮我把 map 放大一点?

谢谢

最佳答案

使用:

d3.selectAll('svg').attr("transform", "scale(2)");

让它变大两倍或:

var projection = d3.geo.conicConformal()
.center([2.454071, 46.279229])
.scale(3000)
.translate([width / 2, height / 2])
.attr("transform", "scale(2)");

关于javascript - 修改d3js中 map 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37483714/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com