O'Reilly logo

Learning D3.js 5 Mapping - Second Edition by Lars Verspohl, Oscar Villarreal, Thomas Newton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including the dataset

The necessary data has been provided for you within the data folder, with the filename geo-data.json:

   d3.json('geo-data.json').then(function(data) {     console.log('mexico', data);

We get the data from a Fetch call, as we saw in the previous chapter.

After the data has been collected, we want to draw only those parts of the data that we are interested in. In addition, we want to automatically scale the map to fit the defined height and width of our visualization.

If you look at the console, you'll see that mexico has an objects property. Nested inside the objects property is MEX_adm1. This stands for the administrative areas of Mexico. It is important to understand the geographic data you are using, because other data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required