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 — fix: Improve handling of auto-fitting with many features and the antimeridian on geo traces by camdecoster · Pull Request #7948 · plotly/plotly.js

Conversation

@camdecoster

@camdecoster camdecoster commented Aug 7, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Description

Improve handling of geo trace auto-fitting with multiple features and geometry that crosses the antimeridian.

Closes #7943.

Changes

  • Refactor geo traces to take all feature geometry into account when determining the fit range
  • Add tests for plots involving the antimeridian
  • Add tests for new helpers

Screenshots

Before After
image image

Testing

  • Be on v4.0
  • Load Plotly devtools
  • Enter the following into the browser console:
      Plotly.newPlot(gd, [{
          type: 'choropleth',
          locations: ['CAN', 'USA', 'MEX'],
          locationmode: 'ISO-3',
          z: [3, 2, 1],
          showscale: false
      }], {
          geo: { projection: { type: 'equirectangular' } },
          width: 700, height: 450
      });
  • Note that the plot is split across the antimeridian
  • Switch to this branch
  • Run that snippet again
  • Note the the plot is fitted properly

Notes

  • This change is necessary is because geometry that didn't cross the antimeridian wasn't being normalized in the same way that geometry that did cross the antimeridian was
  • I reworked the way the range is padded as well to better match what happens in getAutoRange
  • A number of geo trace helpers were eliminated/changed/added to support this new method of fitting

Sorry, something went wrong.

Uh oh!

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

All reactions
camdecoster added 4 commits August 7, 2026 15:47
@camdecoster
fix: Improve handling of auto-fitting with many features and the anti…
a062dd8
…meridian on geo traces
@camdecoster
Add tests
834cd87
@camdecoster
Add draftlog
4a83282
@camdecoster
Update baseline images
877b447
emilykl
emilykl reviewed Aug 7, 2026
View reviewed changes
Comment thread src/lib/geo_location_utils.js Outdated
* @param {object} trace - a `fullData` trace
* @param {object} geoLayout - the subplot's `fullLayout` entry
* @return {Array|null} `[west, south, east, north]`, or null whenever
* `fitGeojsonCoords` is empty — in which case the caller falls back to the data.

@emilykl emilykl Aug 7, 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.

I don't like this pattern of describing what the calling function will do. The docstring should document this function's behavior, not the behavior of the calling function.

Suggested change
* `fitGeojsonCoords` is empty — in which case the caller falls back to the data.
* `fitGeojsonCoords` is empty.

Sorry, something went wrong.

Uh oh!

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

All reactions
emilykl
emilykl reviewed Aug 7, 2026
View reviewed changes
Comment thread test/image/baselines/geo_country-names.png

@emilykl emilykl Aug 7, 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.

From a data-visualization perspective, probably better to turn off auto-fitting for this mock.

Sorry, something went wrong.

Uh oh!

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

All reactions
emilykl
emilykl approved these changes Aug 7, 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.

Nice

Sorry, something went wrong.

Uh oh!

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

All reactions
camdecoster added 4 commits August 7, 2026 16:54
@camdecoster
Disable fitbounds for 'peirce quincuncial' projection
605ee93
@camdecoster
Update various_geo_projections mock
5cfb6f8
@camdecoster
Update geo_country-names mock
3891636
@camdecoster
Update docstring
d6c57b5
@camdecoster
camdecoster marked this pull request as ready for review August 7, 2026 23:07
camdecoster added 2 commits August 7, 2026 17:13
@camdecoster
Update another baseline image
212c786
@camdecoster
Update one more baseline image
2844e13
@camdecoster camdecoster mentioned this pull request Aug 7, 2026
[BUG]: geo projections lose their D3 default rotation #7949
Open
@camdecoster
camdecoster merged commit dbded83 into v4.0 Aug 7, 2026
163 of 166 checks passed

Uh oh!

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

@camdecoster
camdecoster deleted the cam/7943/handle-polygons-points-antimeridian branch August 7, 2026 23:35
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

No one assigned

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.