errors during react() while drag-selecting
See original GitHub issueI’m trying to upgrade my crossfilter example to be more declarative by using react()
but seeing errors. This is my attempt: https://github.com/plotly/plotly.js-crossfilter.js/blob/23b1ff9bd8dc0a3923caf29e4d3feb960ec31234/script.js
While drag-selecting on top of the Infant Mortality chart, the dashed-line selection box does not appear, and errors appear in the console:
plotly-latest.min.js:7 Uncaught (in promise) TypeError: Cannot read property '0' of undefined
at Object.m.supplyDefaultsUpdateCalc (plotly-latest.min.js:7)
at Object.r.react (plotly-latest.min.js:7)
at redraw (script.js:64)
at n.hist_im_select (script.js:121)
at n.emit (plotly-latest.min.js:7)
at HTMLDivElement.t.emit (plotly-latest.min.js:7)
at plotly-latest.min.js:7
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (7 by maintainers)
Top Results From Across the Web
A component for drag and drop files in React returns error ...
There is a component for uploading files with drag and drop, here is its code: import clsx from 'clsx'; import React, { DragEvent, ......
Read more >Have a bug from the library - Prime Community Forum
I am using a lazy table with multiple sortable colums and when you are sorting more than 1 colum at the same time...
Read more >react-select-table - npm Package Health Analysis - Snyk
react -select-table. A combination of item management (addition, deletion, sorting, etc.) using redux, and a table component to display them.
Read more >react-syntax-highlighter | Yarn - Package Manager
Check out a small demo here and see the component in action highlighting the generated test code here. For React Native you can...
Read more >Smart GWT Release Notes - SmartClient
When the mouse is down, mouseMove() is now fired whenever the mouse is moved over ... Improve logging of JavaScript errors across various...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Alright, managed to reproduce and understand what’s going on here:
Plotly.react
on the same plot, giving it new data arrays.Plotly.plot
to know to recalc is to deletegd.calcdata
.Plotly.plot
bails out because you’re in the middle of a drag:https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_api.js#L139-L145
Plotly.react
the data arrays may have not changed, so we don’t deletegd.calcdata
, we expect it to be there to be relinked to the modified traces.gd.calcdata
I could do various simple things to avoid the particular error seen here (recalc before bailing out of
Plotly.plot
, or use some other signal besides deletinggd.calcdata
, or just check ifgd.calcdata
exists before trying to relink it) but all of those have problems of various severity with the plot data being out of sync with the displayed plot, which are going to bite us down the line in obvious or subtle ways.I think the solution is to make something like
gd._hoverData
andPlots.rehover
but for dragging, so we can get rid of thatgd._dragging
bail out, actually do the replot, then re-establish the partial drag (be it a pan, a zoom, a select…). Obviously this has the potential to be a bit of a project, given all the differentdragmode
settings; but it would also address the use case of streaming (or otherwise changing independent of user interaction) data.@nicolaskruchten we talked about making the select box / lasso part of the figure - and that may still be part of this solution (just as we’d eventually like to have the hover data be part of the figure https://github.com/plotly/plotly.js/issues/1848, but I think the parts of the state that depend explicitly on mouse events (is the mouse up or down, where was it at mousedown) - which are necessary to fully recreate the plot after a mid-drag redraw - should not be part of the figure but should instead be kept as internal state. For one thing we don’t really want the user to be able to say “start this plot out as though the mouse is down.” For another, having this be internal state that we re-initialize after replot would allow us to clear it naturally if the change has obviated that state, like if the subplot was removed,
dragmode
was changed, anything like that.@etpinard also brought up https://github.com/plotly/plotly.js/issues/1640 - an infinite loop created by using the hover event to do something that moves data points around (in that case adding/removing an annotation that changes the axis ranges) such that as soon as a point is hovered it is moved by the update so it’s not hovered on, whereupon it’s moved back again… I’ll comment more over there, but similar loops could be an issue here too.
@nicolaskruchten, I stumbled on a similar issue, but with different origin. I could not find a specific issue for this exact problem, but saw mentions of related issues on https://github.com/plotly/plotly.js/issues/2687 and https://github.com/plotly/plotly.js/issues/3305.
The error is not repetitive, and I still didn’t figure out the exact conditions reproduce it. Is there something I could do about it?
Im using plotly.js ^1.58.4, with react-plotly.js ^2.5.1, to render a scatter3d plot that
The structure of my Plot component is as follows, and the React component is updated when data, layout and config properties change.
Detailed browser error view: