GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: Update geo trace fitbounds default to 'locations' by camdecoster · Pull Request #7895 · plotly/plotly.js

Conversation

@camdecoster

@camdecoster camdecoster commented Jul 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Updates the fitbounds default value to "locations" for geo traces. Also fixes (previously unknown) bug related to using zoom buttons with fitbounds active.

Closes #7885

Changes

  • Changes default
  • Update schema and types
  • Persists view attributes to layout
  • Added check for fitbounds incompatible projections (craig/satellite/albers-usa)
  • Updates tests per above changes

Videos

Before (fitbounds: false, default)

Screencast.From.2026-07-09.15-30-04.mp4

Before (fitbounds: "locations")

Screencast.From.2026-07-09.16-51-23.mp4

After (fitbounds: "locations", default)

Screencast.From.2026-07-09.15-29-05.mp4

Testing

  • Be on master
  • Load Plotly devtools
  • Open the mock geo_orthographic
  • Note that the plot is centered on the US/Canada
  • Switch to this branch
  • Open the same mock
  • Note that the plot is now centered on Asia

Notes

  • fitbounds used to default to false. This changes the default to "locations".
  • Any plot that wants to maintain the current view calculation will need to pass false to fitbounds
  • This update matches the convention that most mapping libraries use
  • The bug (fixed in this PR) meant that zoom button clicks had no effect on the view when fitbounds was active

Follow up work

  • Antimeridian-aware fitbounds aggregation for choropleth + scattergeo-with-locations
  • Frame/fit asymmetry for non-clipped fitbounds when midLat ≠ 0 (see geo_first with fitbounds: 'locations')
  • Account for arcs when computing fitbounds extents (see geo_legendonly)
  • Antimeridian rotation splitting up lines between points (see geo_multi-geos)
  • Enable fitbounds for choroplethmap
  • Add configurable fitBoundsPadding / maxZoom for map subplot
  • Updating fitboundsIncompatible projections after baseline review (or just get rid of it and deal with projections on a case by case basis)
  • Better handling GeoJSON that spans the globe (see geo_point-selection)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
camdecoster added 15 commits July 9, 2026 14:41
@camdecoster
Linting/formatting
35e356e
@camdecoster
Switch default fitbounds to 'locations' for geo traces
2d1a490
@camdecoster
Save fitbounds computed values to layout
03c1e43
@camdecoster
Persist view attributes during manual zoom operations
a8742c8
@camdecoster
Update tests per new default, view attrs saved to layout
9894fdb
@camdecoster
Add user view attribute gate for fitbounds
82acb12
@camdecoster
Save center lat/lon for clipped projections
0f9af80
@camdecoster
Update tests per gate addition
02b0c92
@camdecoster
Add draftlog
fe45f65
@camdecoster
Replace undefined with null for fitbounds computed values
4f6f122
@camdecoster
Use local variables for calculating zoom button actions
c2b23ea
@camdecoster
Update tests
93055f0
@camdecoster
Update draftlog
5aa17cf
@camdecoster
Add test image generation timeout
195345c
@camdecoster
Add special handling for Albers USA
f04bc14
@camdecoster camdecoster self-assigned this Jul 15, 2026
camdecoster added 3 commits July 15, 2026 15:58
@camdecoster
Add check for projections that don't play well with fitbounds
e470048
@camdecoster
Simplify fitbounds default-setting logic
5feb26a
@camdecoster
Update baseline images
16254c7
@camdecoster
camdecoster marked this pull request as ready for review July 16, 2026 18:59
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_visible_false_override_template.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems somewhat less useful now. Might be worth setting fitbounds: false on this one.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, those dots are great. /s

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_tick0.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test still functions perfectly fine (i.e. if something goes wrong with tick0 for geo plots it will fail), but it might be worth setting a lower zoom level to make it more human-obvious what's going on here. Not a blocker.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to disable fitbounds for this one as well. It's not helping anyone (or the test) to be so zoomed out.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_skymap.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why the new image renders a smaller plot? Not a dealbreaker, but the previous version seems better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funkiness with projections. This is also running into an issue on my TODO list. For now, I'll disable fitbounds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_point-selection.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does fitbounds choose a center when the geoJSON wraps all the way around the globe?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It creates one big bounding box around all of the geometry and finds the smallest gap that contains that box. We use d3-geo to figure that out now, but it used to be @turf/bbox, which didn't handle the antimeridian at all.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_multi-geos.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top plot doesn't look right, why is the orange line forced to wrap off the right edge?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is happening because the smallest gap that contains the points (not the line) is what's shown. Adding the lines to the fit check is something I'm looking into.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_legendonly.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Green dotted line is cut off the top. Maybe this is an existing limitation with fitbounds, if so, it's not the end of the world but let's open an issue.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's an existing issue and it's on my list to work on in a follow up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_fitbounds-scopes.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to disallowing fitbounds with the Albers USA projection.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_fitbounds-locations.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_first.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems not ideal to show less of the southern latitudes when there's no more of the northern latitudes to be shown, would it be possible to add a constraint that the north edge of the map can't be lower than the top of the plot area in the initial render?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look a bit odd, but I think it's correct. It's fitting lat/lon, and the lat fit results in the frame getting pulled down. I'll add it to my follow up list. For now I'll disable fitbounds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_country-names-text-chart.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a fix for this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_choropleth-text.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again not totally clear to me how this centerpoint was chosen.

I mean, there's no reason the center has to be the Europe-centric map we're used to, although that does have the advantage of splitting fewer countries in half.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_choropleth-legend.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here re: centerpoint

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some funkiness with handling coords around the antimeridian with choropleths. I'm working on a fix, but I think that can wait until after the the v4 release. For now, I'll disable fitbounds for this mock.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_africa-insets.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably another one worth editing the mock to set fitbounds: false

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add that and push a fix that should make this look like the original.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/geo_across-antimeridian.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here? This seems wrong

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is! I'll add a fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl reviewed Jul 16, 2026
View reviewed changes
Comment thread test/image/baselines/canada_geo_projections.png

@emilykl emilykl Jul 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems wrong

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disallowed a few projections because the fitbounds math can lead to undesirable results. In this case, the result looks okay, but now it's not using fitbounds due to the disallow list. For now, I think we should keep the disallow list and I can follow up with a more nuanced approach after v4.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
camdecoster added 4 commits July 16, 2026 16:42
@camdecoster
Skip fitbounds if axis range has been set
122cdd4
@camdecoster
Disable fitbounds for a number of mocks
7dd5c74
@camdecoster
Update mocks affected by axis range fix
087b342
@camdecoster
Merge remote-tracking branch 'origin/v4.0' into cam/7855/update-geo-f…
e85457c
…itbounds-default
emilykl
emilykl reviewed Jul 20, 2026
View reviewed changes
Comment thread src/plots/geo/layout_attributes.js
'Defaults to *false*.'
"If *locations* (default), only the trace's visible locations are considered in the `fitbounds` computations.",
'If *geojson*, the entire trace input `geojson` (if provided) is considered in the `fitbounds` computations.',
'If *false*, the view settings are used as-is; set this to opt out of auto-fitting.'

@emilykl emilykl Jul 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this description to say what zoom and center settings are used if fitbounds is false

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
emilykl
emilykl approved these changes Jul 20, 2026
View reviewed changes

@emilykl emilykl left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look into the geo_point-selection mock, but otherwise LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster
camdecoster merged commit ff9d215 into v4.0 Jul 20, 2026
83 of 84 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@camdecoster
camdecoster deleted the cam/7855/update-geo-fitbounds-default branch July 20, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@emilykl emilykl emilykl approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@camdecoster camdecoster

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@camdecoster @emilykl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.