Closed cardinalgeo closed 1 year ago
Of note, the above also occurs upon refreshing the app. And in contrast to the plotly figure, the vtk widget does not reset in either situation (i.e., opening/closing drawer or refreshing the app).
This is not a trame bug, this is a bug in your application.
Let me explain.
The issue you are facing is because, you are using a SizeObserver
which will trigger the regeneration of the chart (python side) on every size change. And since you are not tracking the zoom (using events so the server knows about it), you will reset the chart and therefore the zoom.
So you have 2 possibles solutions.
First one: Fix the size (mainly height, as the width can be dynamic using 100%) and do not use the size observer.
Second one: Keep track of the zoomed area by listening to the chart and making sure that when you update the chart (from the server) you take into account that information.
HTH,
Seb
Describe the bug
Upon closing or opening a drawer in an app containing a plotly figure, the figure is reset. For example, if the user zooms into a plotly plot, upon closing or opening a drawer, the axes ranges reset and the plot "unzooms." This behavior is unexpected, as a user may want to zoom into a region of interest in, for example, a scatter plot to better resolve the individual points when making selections. Closing or opening the drawer should not reset the figure, as this requires the user to repeatedly re-zoom into the region of interest — a cumbersome act.
To Reproduce
Steps to reproduce the behavior:
from trame.ui.vuetify import SinglePageLayout
tofrom trame.ui.vuetify import SinglePageWithDrawerLayout
with SinglePageLayout(server) as layout:
towith SinglePageWithDrawerLayout(server) as layout:
layout.icon.click = ctrl.view_reset_camera
)The code changes discussed above are implemented below: Code
Expected behavior
I expect that the plotly figure should not be reset upon opening or closing the drawer.
Platform:
Device:
OS:
Browsers Affected: