title: How to use d3.js Hierarchy with custom data structure?
body: <p>I have been attempting to load a small dataset into d3.js for use with some other d3 aspects. It only has a depth of two, but I'm struggling to get D3 to load it properly. I've tried the following, which in my mind should work?</p>
  
  <pre><code>let hierarchy = d3
    .hierarchy()
    .children(d =&gt; d.foods)
    .sum(d =&gt; d.total)
  </code></pre>
  
  <p>The data sample in question is:</p>
  
  <pre><code>let data = {
  'SetA': {
      foods: [
          { food: 'Apple', total: 1 },
          { food: 'Banana', total: 1 },
          { food: 'Orange', total: 3 }
      ], label: 'fruits', size: 3
  },
  'SetB': {
      foods: [
          { food: 'Potato', total: 2 },
          { food: 'Carrot', total: 4 }
      ], label: 'vegetables', size: 2
  }
  }
  </code></pre>