This has probably been asked and answered sometime before, but I honestly couldn't find anything asking something quite like this question.
To start, yes - I have seen the
Line Transition demo and the explanations that follow it. What I'm trying to accomplish is slightly different, instead of animating the line to the left and continuously updating it with one data point per interval, I'm trying to update the entire line with either more or less points. Looking for something like:
M x0, y0 L x1, y1 L x2, y2 L x3, y3
↓ ↓ ↓ ↓ ↓ ↓ ↓
M x0, y1 L x1, y2 L x2, ... L xn, yn
That is - from the line of it's old number of points to the new line of greater than (or less than) points without causing quirkiness in the animation. This is difficult because I'd need to re-draw the line (as it is) with the same number of points as the new data but interpolating between each point so that it renders exactly the same as before.
I can't quite think of some way to accomplish this with that approach, but maybe there's a different and better way?
A demonstration of this behavior using the standard
.transition()
.duration(n)
.attr('d', line);
can
be viewed here. I use attrTween() in my example because I think that there may be a way of using d3.interpolate() to create this animation, but I'm demonstrating how .attr() would use the same format.
Thanks,
matt