[Python] Dash / Plotly: 3D camera resets on every update on mobile (Android/iOS)

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developping a Dash app with a 3D plot (dcc.Graph + plotly.graph_objs) that includes interactive features like cube overlays and filtering. The 3D scene works well on desktop — but on mobile (Android & iOS), the camera resets every time the graph updates, even when uirevision="lock" is set.

    Here’s how I build the layout:

    layout = go.Layout(
    scene=dict(
    xaxis=dict(title='Conductivity'),
    yaxis=dict(title='Temperature'),
    zaxis=dict(title='pH'),
    ),
    margin=dict(l=0, r=0, b=0, t=40),
    dragmode='lasso',
    uirevision='lock' # expected to preserve camera


    )

    I also try to preserve relayoutData['scene.camera'] like this:

    if relayoutData and 'scene.camera' in relayoutData:
    layout['scene']['camera'] = relayoutData['scene.camera']


    The problem:

    On desktop, everything works as expected => the camera stays in place even after updates (new points, new filters, cube added). On mobile browsers (tested on Chrome/Android + Safari/iOS): Zoom/pan is lost after any update.

    What I’ve tried :

    1)Using uirevision="lock" → works only on desktop

    2)Using relayoutData to store and reassign the camera → ignored on mobile

    3)Wrapping dcc.Graph in dcc.Loading to avoid re-render → same result

    4)Avoiding full figure update → not practical (I need the updates)

    Is this a known limitation of Plotly / Dash on mobile ? and is there a way to fully lock or persist camera view on mobile devices?

    Continue reading...

Compartilhe esta Página