title: update d3 pie chart with new data.json
body: <p>I have a dynamic data source that creates a new json in the browser frequently.</p>
  
  <p>I was able to create a pie chart from this json using the code below (also at <a href="http://jsfiddle.net/fg9MU/1/" rel="nofollow">this fiddle</a>)</p>
  
  <pre><code>var data=[{"crimeType":"mip","totalCrimes":24},{"crimeType":"theft","totalCrimes":558},{"crimeType":"drugs","totalCrimes":81},{"crimeType":"arson","totalCrimes":3},{"crimeType":"assault","totalCrimes":80},{"crimeType":"burglary","totalCrimes":49},{"crimeType":"disorderlyConduct","totalCrimes":63},{"crimeType":"mischief","totalCrimes":189},{"crimeType":"dui","totalCrimes":107},{"crimeType":"resistingArrest","totalCrimes":11},{"crimeType":"sexCrimes","totalCrimes":24},{"crimeType":"other","totalCrimes":58}];
  
  
  var width = 800,
  height = 250,
  radius = Math.min(width, height) / 2;
  
  var color = d3.scale.ordinal()
  .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);
  
  var arc = d3.svg.arc()
  .outerRadius(radius - 10)
  .innerRadius(radius - 70);
  
  var pie = d3.layout.pie()
  .sort(null)
  .value(function (d) {
  return d.totalCrimes;
  });
  
  
  
  var svg = d3.select("body").append("svg")
  .attr("width", width)
  .attr("height", height)
  .append("g")
  .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
  
  var g = svg.selectAll(".arc")
      .data(pie(data))
      .enter().append("g")
      .attr("class", "arc");
  
  g.append("path")
      .attr("d", arc)
      .style("fill", function (d) {
      return color(d.data.crimeType);
  });
  
  g.append("text")
      .attr("transform", function (d) {
      return "translate(" + arc.centroid(d) + ")";
  })
      .attr("dy", ".35em")
      .style("text-anchor", "middle")
      .text(function (d) {
      return d.data.crimeType;
  });
  </code></pre>
  
  <p>This data updates frequenty so what would be the best way to update the pie? Look at <a href="http://jsfiddle.net/fg9MU/2/" rel="nofollow">this fiddle</a>. Here I have another json called data2. </p>
  
  <p>How could I simply replace data with data2 and have the pie animate/update? </p>
  
  <p>Note: on some updates values could == 0 </p>