Skip to content

Replot on drag #3716

New issue

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

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

Already on GitHub? # to your account

Merged
merged 7 commits into from
Apr 5, 2019
Merged

Replot on drag #3716

merged 7 commits into from
Apr 5, 2019

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Apr 2, 2019

an attempt at fixing #3305

In brief, this PR completely 🔪

// if the user is trying to drag the axes, allow new data and layout
// to come in but don't allow a replot.
if(gd._dragging && !gd._transitioning) {
// signal to drag handler that after everything else is done
// we need to replot, because something has changed
gd._replotPending = true;
return Promise.reject();
} else {
// we're going ahead with a replot now
gd._replotPending = false;
}

and its replotPending logic and replaces it with a Plots.redrag handler called at the end Plotly.plot similar to Plots.rehover. Bye bye uncaught promises and console errors 👋

The current solution most likely will break in some scenarios, but it is enough to fix (I think) all the problematic examples listed in #3305 (comment), see:

For example, dragging under dragmode:'zoom' in an extendTraces interval looks like:

Peek 2019-04-02 16-51

Notice: we're not trying to resize the zoombox, but instead we update its corresponding data-space range as new (auto-ranged) data pts come in.


cc @plotly/plotly_js

etpinard added 4 commits April 2, 2019 15:59
... instead of `zoomlayer`, making it easier to reuse.
- setup in a similar way to Plots.rehover
- stash drag dx/dy values on gd._dragdata,
  call drag handler `moveFn` after redraw
- 🔪 gd._replotPending logic !
- 🔪 gd._dragging Promise.reject !
@jonmmease
Copy link
Contributor

Awesome! Will this also work for updating images?

The reason I ask is that I'd like to be able to eventually update this datashader example (https://plot.ly/python/change-callbacks-datashader/#image-updates-on-drag-zoom) to update the image during drag, not only on drag completion. To do this I think we would need to pick #2606 up again to have access to the relayout events during drag.

@etpinard
Copy link
Contributor Author

etpinard commented Apr 3, 2019

Will this also work for updating images?

it should.

etpinard added 2 commits April 3, 2019 17:28
- 1 extendTraces during drag case
- 1 plotly_relayout callback
- 1 plotly_selecting callback
@etpinard
Copy link
Contributor Author

etpinard commented Apr 3, 2019

Alright, I added some tests (mostly inspired by past bug reports) and after more than a day hunting around for edge cases, I'm fairly confident this solution is pretty good.

I'll tag this as reviewable.

Copy link
Contributor

@archmoj archmoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! @etpinard
Please find my questions below.
I will send the second pass review with more testing on Friday.
Thanks.

@archmoj
Copy link
Contributor

archmoj commented Apr 5, 2019

Awesome PR.
💃 💃 💃
💃 💃
💃

@etpinard etpinard merged commit 866a149 into master Apr 5, 2019
@etpinard etpinard deleted the replot-on-drag branch April 5, 2019 15:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants