Linked Questions

Popular Questions

I'm following along Mike Bostock's choropleth tutorial.

<!DOCTYPE html>
      <script type = "text/javascript" src = ""></script>
      <script type = "text/javascript" src=""></script>
      <script type = "text/javascript" src=""></script>
      <script src="[email protected]"></script>

         body { font-family: Arial; }

         us = d3.json("[email protected]/us/10m.json")

         const width = 960;
         const height = 600;
         const path = d3.geoPath();

         const svg ="svg")
            .style("width", "100%")
            .style("height", "auto");

         .data(topojson.feature(us, us.objects.counties).features)
         .attr("fill", d => color(data.get(
         .attr("d", path)
         .text(d => format(data.get(;

         format = d3.format("")     


I'm getting the error Uncaught TypeError: Cannot read property 'counties' of undefined at check.html:32 (anonymous) @ check.html:32

My understanding is that the svg-command adds a group element as a child to the svg element. It selects the path variable and binds the counties which are features in the topojson file. The topojson.feature() command converts the data to GEOJson.

All the counties get selected in the enter() command since there is no "g" in the html block. Then, the following commands give each of them a color and a name.

Is topojson.feature still in use?

Related Questions