D3.js tutorial - 20 - Maps in D3

d3Vienno · 62K views · 2013 · 10:59

Open on YouTube

Data visualization & information designWeb developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when building a D3 map from GeoJSON, usually in questions where the map renders blank or at the wrong scale.

Recommended by 0 people across 0 different months, 2013 to 2016.

What it is

Part 20 of d3Vienno's D3.js tutorial series, a roughly 11-minute screencast on drawing maps in D3. It walks through loading a GeoJSON file, setting up a Mercator projection and a path generator, and rendering regions as SVG paths.

What people said

Cites NumenorForLife · 2013-07 · Stack Overflow · on “Failing to Load geoJSON for d3.js in Gist”

I am attempting to check whether I could correctly implement d3Vienno's code ( [this video] ) from his d3.js Map Tutorial with geoJSON for NYC. However, my Gist is failing to properly display the map, and no errors are being thrown, as you can see here: [LINK] . I would very much appreciate any recommendations as to why this might not be working. I suppose it could be due to a lack of styling, but I am not sure.

Cites kabr · 2013-10 · Stack Overflow · on “Draw a map with D3.js: How to get the right scale() and translate()?”

I want to draw a map of german districts. My code follows the youtube-tutorial of d3vienno [this video] . When I open the page, it is blank. When I inspect the code, the svg and g elements are there. I already know that I have to adjust scale() and translate(). So I tried different values and read posts here on stackoverflow that a dealing with the topic. Nevertheless, nothing worked. Can you help? This is the site: [LINK] var canvas = d3.select("body").append("svg") .attr("width", 700) .attr("height", 700) d3.json("data/gemeinden_bayern.geojson", function(data) { var group = canvas.selectAll("g") .data(data.features) .enter() .append("g") var projection = d3.geo.mercator().scale(7300).translate(

Cites user2234003 · 2015-05 · Stack Overflow · on “Map NOT loading using d3.js?”

So basically there's nothing showing in the console so i guess there's no error. However, i added this line d3.select("body").append("p").text("new paragraph!"); to make sure that d3 is working fine and the only thing showing in the page is "new paragraph!" nothing else !! and regarding the source code i took it from this video tutorial [this video] you can fine a lot of geojson files available online [LINK]

Cites Mitch Kroska · 2016-04 · Stack Overflow · on “How to use d3 to display geojson file”

I'm have a geojson file of the wards of Chicago and I'm trying to render it on the browser using d3. Here is the geojson file [LINK] . You click on export, then you'll see download geojson. Also here is the js script I have to render it. : <script> var geoCanvas = d3.select("body").append("svg") .attr("width", 1000) .attr("height", 1000) d3.json("wards-chi.geojson", function(data) { var group = geoCanvas.selectAll("g") .data(data.features) .enter() .append("g") var projection = d3.geo.mercator().scale(100000); var path = d3.geo.path().projection(projection); var areas = group.append("path") .attr("d", path) .attr("class", "area") .attr("fill", "steelblue"); }); </script> And here [LINK] is h