title: updating d3 data using intervals
body: <p>Im new to D3. i'm trying to update my data every 5 secs using an setInterval to update my data array. I want to only run the interval on the data and not my entire D3 code. Also I only want to append the newly added index to the data once the interval has ran, while keeping the previously added interval data on the chart. A Fiddle would be great. Thanks</p>
  
  <pre><code>//DATA//
      $scope.reg = data;
      var rate  = parseInt($scope.reg);
           var bardata=[];
        setInterval(function(){
      bardata.push(rate);
      console.log("REG", $scope.reg, bardata);
      }, 5000);
  
  //D3//
                  var height = 500,
                          width = 600,
                          barwidth = 50,
                          barOffset = 5
                d3.select('#showResponder').append('svg')
                        .attr('width', width)
                        .attr('height', height)
                        .style('background', 'lightgrey')
  
                        .selectAll('rect').data(bardata) //this needs to update every 5 secs
                        .enter().append('rect')
                        .style('fill','black')
                        .attr('width', barwidth)
                        .attr('height', function(d){return d;})
  
                  .attr('x', function(d,i){
                      return i *(barwidth + barOffset)
                  })
  
                  .attr('y', function(d){
                      return height - d;
                  })
  </code></pre>