title: Message "d3.js TypeError: n is undefined" (for D3 world map with force layout)
body: <p>I was trying out the code from this site: <a href="http://bl.ocks.org/bycoffe/3230965" rel="nofollow noreferrer">http://bl.ocks.org/bycoffe/3230965</a></p>
  
  <p><img src="https://i.stack.imgur.com/OHTOf.png" alt="enter image description here"></p>
  
  <p>I keep having the error that "n is undefined".</p>
  
  <p>Upon further scaling down, i have come to the conclusion that the problem is with these lines:</p>
  
  <pre><code>(function() {
        var width = 800;
        var height = 700;
        var padding = 10;
        var k;
        var node;
  
        var pixelLoc = d3.geo.mercator();
        pixelLoc.scale(2000);
  
        svg = d3.select('#map')
                .append('svg:svg')
                .attr('width', width)
                .attr('height', height);
  
        d3.json('coordinates.json', function(coordinates) {
  
          var coords = [];
          var xs = [];
          var ys = []
          for (alias in coordinates) {
            coords.push(coordinates[alias]);
            xs.push(coordinates[alias][0]);
            ys.push(coordinates[alias][1]);
          }
  
          var minX = d3.min(xs);
          var maxX = d3.max(xs);
          var xScale = d3.scale.linear().domain([minX, maxX]).range([-50, -30]);
          var minY = d3.min(ys);
          var maxY = d3.max(ys);
          var yScale = d3.scale.linear().domain([minY, maxY]).range([-20, -10]);
  
          d3.json('medals.json', function(medals) {
  
              var pointScale = d3.scale.sqrt().domain([0, 80]).range([0, 75]);
  
               nodes = []
  
               for (i=0; i&lt;medals.length; i++){
                  node = medals[i];
                  node.coordinates = coordinates[node.alias];
                  node.cx = xScale(pixelLoc(node.coordinates)[0]);
               }
  
          })
  </code></pre>
  
  <p>The issue arises with the last line:</p>
  
  <pre><code>node.cx = xScale(pixelLoc(node.coordinates)[0]);
  </code></pre>
  
  <p>However, I still have no idea what do they mean by "n is undefined". Anybody able to help?</p>