Skip to content
Advertisement

Is there a way to extract the current frame from a plotly figure?

Basically, I have a plotly animation which uses a slider and pause/play buttons to go through a dataset. I want to extract the number of the current frame (i.e., the current index in the ‘steps’/‘frames’ lists which the slider is on) in a Dash callback, so that I can update a table based on the main graph.

For example, in this situation:

Dash app with slider

I would like to be able to get ‘6’, the current step number, from the figure.

Here is some example code with a toy dataset, but the same basic UI and structure (from above, minus the buttons to reduce length of code block):

JavaScript

Basically, in that callback, I just want to get the current index of the slider, i.e. the current frame that the animation is on. It’s displayed by the ‘Steps’ tag above the slider, so it clearly exists somewhere, but I can’t find it for the life of me (tried going through the Github source code, but couldn’t locate it).

I would really appreciate any help with this! My dataset is fairly large (20 mb) and doesn’t fit into browser memory, so I haven’t had much luck with a Dash solution using dcc.Slider and dcc.Graph that is still performant.

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement