Implement per-frame animation durations for Figure and FigureWidget#5601
Open
FredericoMendes10 wants to merge 2 commits into
Open
Implement per-frame animation durations for Figure and FigureWidget#5601FredericoMendes10 wants to merge 2 commits into
FredericoMendes10 wants to merge 2 commits into
Conversation
Add set_frame_durations(durations) to Figure, which accepts a scalar
or a list of values (in milliseconds) and stores the duration on each
frame. Example:
fig = go.Figure(frames=[go.Frame(name=0), go.Frame(name=1)])
fig.set_frame_durations([200, 2000])
When to_html detects per-frame durations it generates a custom
JavaScript playback loop instead of the global Plotly.animate(null)
call, so each frame is displayed for its own duration.
Also add animate_frames(frames_data, durations) to FigureWidget for
the widget use-case, delegating to batch_animate per frame.
Closes plotly#5362
Co-authored-by: Mário Vaz Silvestre <mario.silvestre@tecnico.ulisboa.pt>
Contributor
|
Thanks for the PR! One of our team members will review it soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #5362
Description of change
Adds
set_frame_durations(durations)toFigureandanimate_frames(frames_data, durations)toFigureWidget, allowing each animation frame to have its own duration in milliseconds. When per-frame durations are set,to_htmlgenerates a custom JavaScript playback loop instead of the globalPlotly.animate(null)call.Demo
https://youtu.be/qyjkXgh-Tf8
Testing strategy
Added
tests/test_animation/test_set_frame_durations.pywith 174 lines covering: scalar vs list durations, validation errors (wrong length, negative values, non-numeric), chaining behaviour, and HTML output containing the custom JS loop.Additional information
Co-authored with Mário Vaz Silvestre (@MarioSilvestre2901).
Guidelines