title: Sankey Diagram in d3
body: <p>I'd like to run the example of a sankey diagram from bl.ocks.org (<a href="http://bl.ocks.org/d3noob/c2637e28b79fb3bfea13" rel="nofollow noreferrer">http://bl.ocks.org/d3noob/c2637e28b79fb3bfea13</a>), but when I run it with</p>
  
  <pre><code>python -m SimpleHTTPServer 8888 &amp;
  </code></pre>
  
  <p>from the folder with index.html, sankey.js and sankey-formatted.json in the following line </p>
  
  <pre><code>source.sourceLinks.push(link);
  </code></pre>
  
  <p>Gives an error:</p>
  
  <pre><code>sankey.js:91TypeError: undefined is not an object (evaluating 'source.sourceLinks.push')
  </code></pre>
  
  <p>The function this code is from is:</p>
  
  <pre><code>  links.forEach(function(link) {
    var source = link.source,
        target = link.target;
    if (typeof source === "number") source = link.source = nodes[link.source];
    if (typeof target === "number") target = link.target = nodes[link.target];
    source.sourceLinks.push(link);
    target.targetLinks.push(link);
  });
  </code></pre>
  
  <p>and my json file is:</p>
  
  <pre><code>{
  "nodes": [
  {
    "name": "Africa"
  }, 
  {
    "name": "America"
  }, 
  ...
  ],
  "links":[
  {
    "source": "Africa", 
    "target": "America", 
    "value": 1
  }, 
  {
    "source": "America", 
    "target": "Africa", 
    "value": 2
  }, 
  ...
  ]}
  </code></pre>