简体   繁体   中英

modifying the size of a map in d3js

I made a map using d3.js with help from code provided in http://www.datavis.fr/index.php?page=map-population , everything works however I am not able to figure out how to resize the map, actually I want to make it bigger but when I tried to modify :

var width = 600, height = 550;

it didn't work, it only made the scale and the map collide.

width and height also appear in :

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");

I'm assuming that's why it doesn't work ? Can anyone help me make the map bigger please ?

Thank you

Use :

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

to make it twice bigger or :

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

也发生在我身上,更改比例不会生效,我查看了我的 geojson 文件,发现也有翻译和比例值

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM