Jean
Jean

Reputation: 429

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

Upvotes: 1

Views: 1372

Answers (2)

Harvester Haidar
Harvester Haidar

Reputation: 553

happened to me too where changing the scale will not take effects, I looked into my geojson file and found out there was translate and scale values too

Upvotes: 0

Tim B
Tim B

Reputation: 1983

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

Upvotes: 3

Related Questions