plotly / plotly/plotly.js

[BUG]: `layout.uirevision` doesn't play well with map subplot auto-fit

Open
#7,907 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good for agent P2 plotly-internal size: 3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Description

When a map subplot uses fitbounds, layout.uirevision fails to preserve the user's subsequent pan/zoom across Plotly.react calls. The map snaps back to the auto-fit view even when the uirevision value is unchanged.

Screenshots/Video

https://github.com/user-attachments/assets/48f4da34-d74f-4958-a874-2bd9a3844181

Steps to reproduce
  • Be on v4.0 (or the default branch after it gets released)
  • Plot a scattermap with uirevision set and no explicit center/zoom:
    Plotly.newPlot(gd, [{
      type: 'scattermap',
      lon: [-75, -74, -73],
      lat: [40, 41, 42],
      mode: 'markers'
    }], {
      uirevision: 'v1',
      width: 400,
      height: 400
    });
    
  • Pan the map with the mouse
  • Call Plotly.react with the same uirevision:
    Plotly.react(gd, gd.data, { uirevision: 'v1', width: 400, height: 400 });
    
  • Note that the map snaps back to the auto-fit view instead of keeping the panned view
Notes
  • Discovered while working on #7884. The auto-fit and zoom-button behaviors landed there; this uirevision integration was deferred as out-of-scope.
  • This works correctly for cartesian axes (via autorange) and for map subplots when the user has supplied an explicit center/zoom from the start. It only fails on the auto-fit path.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the scattermap case with unchanged layout.uirevision, then trace the map subplot auto-fit path during Plotly.react. Compare it with the existing explicit center/zoom behavior and the cartesian autorange behavior. Done means a user's pan or zoom is preserved across Plotly.react calls when uirevision is unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.