Accepted answer

If a single datum attribute can be checked to see if the bound data has changed, one method would be to track that attribute as a property using and a custom property such as type. When appending the data you could define the property fairly easily:

  .property("type",function(d) { return d.type; });

Then, when updating, you could filter based on which data are matching or not matching the property:
    .filter(function(d) {
      return d.type !="type")

This filter will return those elements that have changed their type. Now we can re-assign the property to reflect the new type and transition those filtered elements.

The snippet below should demonstrate this, the datum is just a number one or two (represented by blue and orange), and is used to set the property type. Click on the svg to update the data, only those circles which change their datum will temporarily change their radius, while also changing their color to reflect their new datum.

var svg ="body")
var circles = svg.selectAll("circle")
  .attr("cy",function(d,i) {
    return Math.floor(i/5) * 40 + 20;
  .attr("cx", function(d,i) {
    return i%5 * 40 + 20
  .attr("r", 8)
  .attr("fill",function(d) { return (d) ? "steelblue" : "orange"})
  .property("type",function(d) { return d; });
// update on click:
svg.on("click", function() {
    .filter(function(d) {
      return d !="type") // filter out unchanged data
    .property("type",function(d) { return d; })  // update to reflect new data
    .attr("r", 20)
    .attr("fill",function(d) { return (d) ? "steelblue" : "orange" })

function data() {
  var output = [];
  d3.range(20).map(function(d) {
  return output;
<script src=""></script>

Related Query