Animate move along x axis

I have a plotly that I want to animate by moving traces along the x axis. It’s similar to this codepen:

which adds an offset value to each point in the curve:

[trace[0]+x, trace[1]+x, trace[2]+x, trace[3]+x, trace[4]+x]

except that I have a couple thousand points in many traces, making it slow to compute all new x’s.
Is there a way to animate so that I can move a whole trace in bulk, w/o having to apply an offset to each point in the curve?
Thanks!

I’d recommend computing frames beforehand and making your button animate between named frames.

See https://plot.ly/javascript/animations/#defining-named-frames-with-plotlyaddframes for more info.

Thanks for the response, @etienne, but it does not look really feasible that way. We’ll need at least 4 animation positions, each w/ ~50 curves, each curve ~1500 points in the X axis, which translates into ~300k add computations. The app will take a hit in client wait time. I need something more straight, the plots are all already computed, all I need is fiddling w their offset. Thanks again anyway.

That doesn’t sound like a big enough number to cause issues. Maybe you’re misunderstanding what I meant by precomputing frames. Here’s an example: https://codepen.io/etpinard/pen/VxaBqB?editors=0010

I did understand the precompute w/ frames. 300 thousand still sounds like a lot to me, but I’ll give it a try, thanks!