title: "TypeError: r is null" when creating d3 pie chart
body: <p>I'm using d3 v4.  I'm trying to create a simple pie chart using the below code</p>
  
  <pre><code>var svg = d3.select("svg"),
      width = +svg.attr("width"),
      height = +svg.attr("height"),
      radius = Math.min(width, height) / 2,
      g = svg.append("g").attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
  
  var color = d3.scaleOrdinal(["#98abc5", 
                   "#8a89a6", 
                   "#7b6888", 
                   "#6b486b", 
                   "#a05d56", 
                   "#d0743c", 
                   "#ff8c00",
                   "#e34d01",
                   "#ccff05",
                   "#3e7eca",
                   "#aa0092",
                   "#b32e4f"]);
  
  var pie = d3.pie()
      .sort(null)
      .value(function(d) { return d.market_cap; });
  
  var path = d3.arc()
      .outerRadius(radius - 10)
      .innerRadius(0);
  
  var label = d3.arc()
      .outerRadius(radius - 40)
      .innerRadius(radius - 40);
  
  var csvData = "currency,market_cap";
  csvData += "Ethereum,36536577384"; 
  csvData += "Ripple,9562570727"; 
  csvData += "Bitcoin Cash,10407237657"; 
  csvData += "Litecoin,4537371026"; 
  csvData += "NEM,2962953000"; 
  csvData += "Dash,2903791940"; 
  csvData += "IOTA,2289563023"; 
  csvData += "Ethereum Classic,1955610226"; 
  csvData += "NEO,1599450000"; 
  csvData += "Monero,2170429814"; 
  csvData += "Stratis,703350671"; 
  csvData += "Bitcoin,80149315484"; 
  var data = d3.csvParse(csvData);
  data.forEach(function(d) {
    d.market_cap = +d.market_cap;
    return d;
  });
  
  
    var arc = g.selectAll(".arc")
      .data(pie(data))
      .enter().append("g")
        .attr("class", "arc");
  
    arc.append("path")
        .attr("d", path)
        .attr("fill", function(d) { return color(d.data.currency); });
  
    arc.append("text")
        .attr("transform", function(d) { return "translate(" + label.centroid(d) + ")"; })
        .attr("dy", "0.35em")
        .text(function(d) { return d.data.currency; });
  </code></pre>
  
  <p>I created a demo here -- <a href="https://jsfiddle.net/rgw12x8d/12/" rel="nofollow noreferrer">https://jsfiddle.net/rgw12x8d/12/</a> .  However, upon running the code, it results in a cryptic </p>
  
  <pre><code>TypeError: r is null
  </code></pre>
  
  <p>What does this mean, but more importantly, how do I resolve it?</p>