Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range slider emits relayout evt on mousemove, should be only on mouseup #2216

Open
gregorybleiker opened this issue Dec 19, 2017 · 12 comments
Open
Labels
bug something broken P3 not needed for current cycle

Comments

@gregorybleiker
Copy link

I have had the need to do something after the rangeslider had changed (update the min/max somewhere else on the page). I did not find any event that fired only after the slider had been released (a.k.a. mouseup) so I changed the rangeslider/draw.js:

function mouseUp() {
            dragCover.removeEventListener('mousemove', mouseMove);
            dragCover.removeEventListener('mouseup', mouseUp);
            Lib.removeElement(dragCover);
// --> new code
            gd.emit('plotly_rangesliderend', {
                axis: axisOpts,
                opts: opts
// --> end new code
            });

Is this anything that would be merged? Should I do a PR?

@etpinard
Copy link
Contributor

Hmm. That's interesting. One can already detect range slider updates by listening to plotly_relayout.

Can ask in what context a range-slider-specific event might become useful?

@gregorybleiker
Copy link
Author

plotly_relayout fires permanentyl during drag (I'd have to debounce). Actually, I oversimplified the example. Based on the range slider of one graph several other graphs get updated, so it would be really bad to be doing that continuously during draging.

@etpinard
Copy link
Contributor

plotly_relayout fires permanentyl during drag (I'd have to debounce)

Hmm. That might be a bug here. It should only fire on mouseup (just like regular zoombox dragmoode: 'zoom' interactions).

@etpinard etpinard changed the title Feature request/PR for rangeslider end event Range slider emits relayout evt on mousemove, should be only on mouseup Apr 13, 2018
@etpinard etpinard added the bug something broken label Apr 13, 2018
@Rapster
Copy link

Rapster commented Apr 15, 2019

Does anyone found a workaround for this (until it gets fixed)? I need to know what the range is once mouseup

@NixTheMan
Copy link

is there any plans to resolve this bug? Or is there a current workaround??

@MeMeMax
Copy link

MeMeMax commented Jun 24, 2021

We need this as well. Using the range slider currently fires too many events.

@cariacou
Copy link

The bug is still current as of latest Plotly. There is no easy way that I am aware of to:

  • prevent relayouts while dragging the rangeslider
  • get a callback on mouseup only

@czanbaka
Copy link

Has this been resolved, having the same problem years later! If not, does anyone recommend another library?

@jonasvdd
Copy link

Hi, I would also like to see this bug resolved, it would be amazing to add a "debounce" option on the range slider, so that it will only perform an update after mouseup

@ntaylor-ads
Copy link

It has been almost 7 years. How is this not fixed?

@ntaylor-ads
Copy link

Incidentally, it's not too hard to work around this with a clientside callback that debounces the trigger before modifying a dcc.store. Then have whatever callback you wanted subscribed to the trigger instead subscribe to that store. Looks something like this:

from dash import Input, Output, dcc, clientside_callback
plot = dcc.Graph()
dcc.Store(id="debounce")
clientside_callback(
    """
    function(relayout){
        var timeout;
        var later = function(){
            timeout = null;
            console.log(relayout);
            return relayout;
        }
        clearTimeout(timeout);
        timeout = setTimeout(later, 200);
    }
    """,
    Output("debounce", "data"),
    Input(plot, "relayoutData"),
)

@app.callback(
    Output(<target_component>),
    Input('debounce', 'data')
)
def callback(relayout):
    ...

@gvwilson gvwilson self-assigned this Jun 10, 2024
@CarltonHenderson
Copy link

I like the current behavior and do not consider it a bug. I like that I can update my other charts live as the rangeslider is dragged. If you do consider this a bug, and you fix it, please give us a way to use the current behavior.

@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 not needed for current cycle label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests