Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning D3.js Mapping
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning D3.js Mapping

Learning D3.js Mapping

By : Newton, Oscar Villarreal
4.3 (7)
close
close
Learning D3.js Mapping

Learning D3.js Mapping

4.3 (7)
By: Newton, Oscar Villarreal

Overview of this book

If you are interested in creating maps for the web GIS data, this book is for you. Familiarity with D3.js will be helpful but is not necessary.
Table of Contents (9 chapters)
close
close
6
6. Finding and Working with Geographic Data
8
Index

Exit

We've discussed enter and update. We've seen how one determines the starting point of our visualization and the other modifies its attributes based on new data coming in. However, the examples covered had the exact number of data elements with the same properties. What would happen if our new dataset had a different amount of items? What if it has fewer or more?

Let's take the update part of the previous example and modify it a bit to demonstrate what we're talking about (http://localhost:8080/chapter-3/example-5.html). We can explain how this works with two small changes to the rectangles function:

var rectangles = function(svg) {
  var data = makeData((Math.random() * 5) + 1);

Here, we tell the data function to create a random number of data objects:

  var rect = svg.selectAll('rect').data(data);

  // Enter
  rect.enter().append('rect')
    .attr('test', function(d,i) {
      // Enter called 2 times only
      console.log('enter...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY