title: Loading D3.js data from a simple JSON string
body: <p>Most of the examples in gallery load data from TSV files.</p>
  <p>How can I convert the following to use a local json variable instead of TSV data?</p>
  <pre><code>d3.tsv(&quot;data.tsv&quot;, function(error, data) {
  
      var myEntitiesJson = getEntitiesJson(); // &lt;------ use this instead of &quot;data&quot;
      data.forEach(function(d) {
          d.frequency = +d.frequency;
      });
  
      x.domain(data.map(function(d) { return d.letter; }));
      y.domain([0, d3.max(data, function(d) { return d.frequency; })]);
  
      ...
  
      svg.selectAll(&quot;.bar&quot;)
          .data(data)     // &lt;----- bind to myEntities instead
  }
  </code></pre>
  <p>As far as I can tell, I just need to do something to my entitiesJson, in order to <strong>data-fy</strong> it so that the chart could bind to it.</p>
  <p><strong>UPDATE</strong></p>
  <p>I am making some progress. I plugged in my entities from JSON and the graph is starting to take new shape.</p>
  <p>Currently the following code breaks:</p>
  <pre><code>svg.selectAll(&quot;.bar&quot;)
      .data(myEntities)  // &lt;-- this is an array of objects
      .enter().append(&quot;rect&quot;)
  </code></pre>
  <p>This is causing:</p>
  <blockquote>
  <p>Error: Invalid value for  attribute y=&quot;NaN&quot;</p>
  <p>Error: Invalid value for  attribute height=&quot;NaN&quot;</p>
  </blockquote>