Plotly sliders update on mouse release / click

Viewed 334

Using Plotly in Python, how do I make my transitions happen only on mouse release when using sliders?

Here’s how I define my slider:

sliders = [
    {
        'yanchor': 'top',
        'xanchor': 'left', 
        'currentvalue': {'font': {'size': 16}, 'prefix': 'Frame: ', 'visible': False, 'xanchor': 'right'},
        'transition': {'duration': 0.0, 'easing': 'linear'},
        'pad': {'b': 10, 't': 10}, 
        'len': 0.9, 'x': 0.1, 'y': 0, 
        'steps': [{'args': [None, {'frame': {'duration': 0.0, 'easing': 'linear', 'redraw': False},
                                  'transition': {'duration': 0, 'easing': 'linear'}}], 
                   'label': k, 'method': 'animate'} for k in range(n_frames)]
    }
]

fig['layout'].update(sliders=sliders)

Here’s how it is behaving (updates every step when dragging the slider): enter image description here

I would like the frames to update only when I release the mouse or do a click in a specific location of the slider ruler.

1 Answers

What you're looking for here does not seem to be possible unless you're willing to make the leap to . And you should. It's fantastic. And if you do, you can use a dcc.Slider that has a functionality that should fit your needs. And if you're by any chance using JupyterLab, you can show your figures as an app directly in your notebbok.

Unlike the slider available in your fig, following slider will have the "drop-then-calculate" functionality you're looking for. It won't show in the screenshot, but that setup will show a hand icon upon hovering instead of an arrow like in your example.

enter image description here

Related