-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Axes incorrect when updating layout but not data #316
Comments
You have to use
|
React advices against this pattern (updating one state based on another): https://react.dev/learn/you-might-not-need-an-effect#updating-state-based-on-props-or-state |
You can also do it this way if you only want to manage one state.
|
Unfortunately the actual use case that lead to this is a bit more complicated (multiple axis titles, switching between 2D/3D so titles are at layout.(x/y)axis.title or layout.scene.(x/y/z)axis.title, wanting to use those strings elsewhere, etc.) so storing the whole layout as state isn't really feasible. Taking a deep copy of the data object between generation and use is probably the cleanest solution for now |
When updating the layout but passing a constant data object (or a new object but with nested constant objects), the traces stay the same but the axes reset to the defaults as if no data is plotted, causing the graph to be incorrect. The data points can also not be hovered over in this state.
Forcing the plot to redraw (e.g. by clicking 'Reset axes') corrects the plot and creating a deep copy of the data object before passing to the Plot component removes the issue.
Example at https://codesandbox.io/s/agitated-babycat-j9hjb8?file=/src/App.js (issue can be seen when changing text in input)
I have been unable to recreate this with pure plotly.js but I am less familiar with that library, so sorry if the issue is there instead.
The text was updated successfully, but these errors were encountered: