plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.86k stars 1.85k forks source link

Plotly `selected` event infinity loop when using selection 'handles' #6453

Open nlooije opened 1 year ago

nlooije commented 1 year ago

Problem description: It seems that when selecting data, having the data or layout change dynamically (using restyle or relayout respectively) and then selecting additional data (by moving the 'handles') the event handler then goes into an infinite loop. Likely, the relayout due to the reselect causes a reselect which causes a relayout which causes a reselect, etc. etc.

Plotly v2.13+ goes into infinite loop when selecting additional data using the 'handles'. Notice how the 'handles' do not reappear after moving one at the end of gif (has gone into infinite loop): event2 gif

Plotly below v2.13 has no issues because it is not possible to reselect data using the 'handles': event1 gif

Minimum working example: MWE Taken from the example documentation for select-event Note that this is a problem for Plotly v2.13+, the original example uses v1.58 (as illustrated on that page) which doesn't seem to have the problem (because the selection 'handles' to select data in the plot are not implemented prior to v2.13) So this seems to be a regression of some kind.

Steps to reproduce:

  1. Run provided MWE
  2. Using lasso select (or other select tool) select some data (first time should not give any problems)
  3. When using Plotly v2.13+, in the selected data use the 'handles' to select additional data points
  4. Plotly now enters an infinite loop
nlooije commented 1 year ago

It is a combination of selection using the 'handles' AND a restyle/relayout. If I disable the API call to restyle/relayout then selecting additional data using the 'handles' does not cause an infinite loop.