title: Cause of 'd is undefined' error
body: <p>My <em>first</em> call of my redraw function for a 'series' worked but if I called it again for the same 'series' I was getting  'TypeError: d is undefined' at the return d.yEnd line in the following code snippet from my redraw function.</p>
  
  <pre><code>var series = menu.property("value");
  var data = nested[series];
  var columnHeaders = d3.keys(data[0]).filter(function(key) { return key !== "Code" &amp;&amp; key !=="Year" &amp;&amp; key !== "LA" &amp;&amp; key !=="LA2";});
  data.forEach(function(d) {
      var yColumn = new Array();
      var yBegin;
      var yEnd;
      d.columnDetails = columnHeaders.map(function(name) {
        for (ic in innerColumns) {
          if($.inArray(name, innerColumns[ic]) &gt;= 0){
            if (!yColumn[ic]){
              yColumn[ic] = 0;
            }
            yBegin = yColumn[ic];
            yColumn[ic] += +d[name];
            return {name: name, column: ic, yBegin: yBegin, yEnd: +d[name] + yBegin,};
          }
        }
      });
  
  mytotal= d3.max(d.columnDetails, function(d) {
      return d.yEnd;
  });
  </code></pre>
  
  <p>});</p>
  
  <p>I found that by changing the last two lines to test whether d was undefined as follows my problem was solved but I can't see why the error was occuring in the first place.</p>
  
  <pre><code>    mytotal= d3.max(d.columnDetails, function(d) {
      if (d === undefined){return;}
      return d.yEnd;
  });
  </code></pre>
  
  <p>Inspecting the object showed that whereas columnDetails had 9 objects in the first call, subsequenty it had 10 but that tenth was undefined. I can't see why it should have grown. Can anyone suggest what was going on?</p>