Skip to content

[BUG] dcc.Graph loses zoom state with unchanged uirevision #4093

Open

Description

@TGeary

Describe your context

dash                 4.4.1

Describe the bug

Starting with Dash 4.4.1, the zoom state of a dcc.Graph figure is reset when a callback is triggered that returns a new figure, despite uirevision=True. I've created a simple example that toggles the legend visibility below.

Observed behavior (as seen in Dash 4.4.1): After the user zooms or pans and clicks the toggle button, the zoom state is reset.

Simple example:

import plotly.graph_objects as go
from dash import Dash, Input, Output, dcc, html

app = Dash(__name__)


def make_figure(showlegend=True):
    fig = go.Figure(
        go.Scatter(
            x=list(range(10)),
            y=[x**2 for x in range(10)],
        )
    )

    fig.update_layout(
        showlegend=showlegend,
        uirevision=True,
    )

    return fig


app.layout = html.Div(
    [
        html.Button(
            "Toggle legend",
            id="toggle-legend",
            n_clicks=0,
        ),
        dcc.Graph(
            id="graph",
            figure=make_figure(),
        ),
    ]
)


@app.callback(
    Output("graph", "figure"),
    Input("toggle-legend", "n_clicks"),
)
def toggle_legend(n_clicks):
    return make_figure(showlegend=n_clicks % 2 == 0)


if __name__ == "__main__":
    app.run(debug=True)

Expected behavior

As seen in Dash 4.4.0, after the user zooms or pans and clicks the toggle button, the zoom state does not change.

Screenshots

N/A

Activity

  1. camdecoster commented on Oct 27, 2026

    @camdecoster
    Contributor

    Thanks for reporting this! Our team will look into this when we have time, but it might take a while. If you want to help (and have time), you could investigate what change occurred.

  2. AnnMarieW commented on Oct 27, 2026

    @AnnMarieW
    Collaborator

    I suspect it was this change that was added in v4.4.1: #3882

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething brokensize: 3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions