Responding to tick events during d3 transitions

I have an svg line element that points to an svg rectangle element. When the rectangle moves, the line should follow it. Is there a way to do this when the rectangle moves with transition d3? I am looking for something that allows me to respond to each tick transition of a rectangle. A similar situation exists for simulation simulation :

force.on("tick", function() {
  link.attr("x1", function(d) { return d.source.x; })
     .attr("y1", function(d) { return d.source.y; })
     .attr("x2", function(d) { return d.target.x; })
     .attr("y2", function(d) { return d.target.y; });

  node.attr("cx", function(d) { return d.x; })
     .attr("cy", function(d) { return d.y; });

});

This can be used to move two elements at each time step. Can this be done for arbitrary transitions in the absence of a layout? It seems he transition.each()can do this if he could listen to the tick transition event, but he can only listen to trigger the transition and the final events.

, , .

+4
2

tick , , . - , . .

rect.transition().attr("x", newX).attr("y", newY);
line.transition().attr("x2", newX).attr("y2", newY);
+2

transition.tween().

factory. . factory , .

+2

All Articles