Skip to content

[BUG]: geo.fitbounds falls back to the world view when locations mix antimeridian-crossing and normal features #7943

Description

@camdecoster

Description

layout.geo.fitbounds defaults to 'locations' in v4 (it was false in v3). When a choropleth (or scattergeo with locations) plots several locations and at least one crosses ±180°, the auto-fit resolves to a longitude span wider than the globe, so the subplot renders the default world view instead of a fit.

Affected territories are the ones whose features cross ±180°: USA (Aleutians), RUS, FJI, NZL, ATA. USA plus neighboring countries is a very common figure. This only appears when a crossing feature is combined with non-crossing ones.

Steps to reproduce

  • Be on v4.0
  • Run the following snippet in Plotly devtools:
     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 view shows the world and splits the USA up

Notes

  • computeBbox returns east unwrapped past 180° for a crossing feature (USA172.6 … 293.0), while non-crossing features stay in negative degrees (CAN-141.0 … -52.6)
  • calcGeoJSON pushes both into one flat array and calls findExtremes, so min = -141, max = 293 → 434°
  • The existing compaction helper in src/plots/geo/geo.js is unreachable here: it is skipped for any choropleth and for any trace with locations, and it operates on point longitudes rather than interval endpoints

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions