Errata: May 31, 2019

Thank you for purchasing D3.js in Action, Second Edition. Please post errors not listed below in the book's LiveBooks errata thread. We'll update this list as necessary.
Corrections made during the second printing are noted below.


Code Listings are Missing Titles

This has been corrected in all formats.

The initial print run is missing numbers for all the listings throughout the book. The grey rectangles above each code snippet should include a listing number and are referenced as such in the text.

Page 32, Figure 1.28

For figure 1.28 the code reads

function(el) {return d <= 40});

And should be:

function(el) {return el <= 40});

Page 87, Figure 3.7

This has been corrected in all formats.

The code underneath Figure 3.7 should not use an arrow function as it does not have the proper context because it's in an arrow function so replace:

d3.select('circle').each((d, i) => {
   console.log(d); console.log(i); console.log(this);
})

With this:

d3.select('circle').each(function (d, i) {
   console.log(d); console.log(i); console.log(this);
})

Page 127

The colors for the chart do not match the code, the colors for the chart are Tweets (Orange), Retweets (Blue), Favorites (Green).

Page 134

This has been corrected in all formats.

The code incorrectly sets "id" as a style and uses attributes when styles make more sense (you can set fill, stroke, etc with attributes but it makes more sense to only use styles unless you're doing it purposefully). The code should read:

d3.select("svg")
   .append("path")
   .attr("id", key + "Area")
   .attr("d", movieArea(data))
   .style("fill", "none")
   .style("stroke", "#75739F")
   .style("opacity", .75)
            

Page 138

This has been corrected in all formats.

The xScale setting for .domain should be:

.domain([1,10])

Page 149

The reference to:

d3.layout.pie

should be:

d3.pie

Page 229

The reference to

.tick(120)

should be replaced with a for loop like this:

for (let i = 0; i < 120; i++) {
     simulation.tick();
  }