title: Update stacked bar chart with transition in D3
body: <p>Using the example listed here: <a href="http://bl.ocks.org/anotherjavadude/2940908" rel="nofollow">http://bl.ocks.org/anotherjavadude/2940908</a> I've been feeling my way around D3 after some success with the basics.</p>
  
  <p>I've built a stacked graph (<a href="https://jsfiddle.net/cwmfjxay/3/" rel="nofollow">Fiddle</a>) and managed to get my initial transitions working, the problem arises when adding new data.</p>
  
  <p>The error I'm receiving is 'Uncaught TypeError: Cannot read property 'length' of undefined'</p>
  
  <p>Here is the .data() where it falls down:</p>
  
  <pre><code>d3.select('rect.stacks')
      .data(function(d){return d;}) // error occurs here
      .attr("x", function(d) { return x(d.x); })
      .attr("width", x.rangeBand()-50)
      .transition()   
      .attr("y", function(d) { return -y(d.y0) - y(d.y); })
      .attr("height", function(d) { return y(d.y); })       
      .duration(1000);  
  </code></pre>
  
  <p>For whatever reason when trying to update the 3D array being passed through has not been formatted correctly and I'm not sure why.</p>
  
  <p>I've tried extracting chunks into functions to and exhausted my knowledge on things to try (which will explain any oddities / spaghetti).</p>
  
  <p>Thanks!</p>