Click to update rect elements using function(d, i)