Skip to content

fix(geo): preserve D3 projection default rotation when user does not set rotation - #7956

Open
waterWang wants to merge 1 commit into
plotly:masterfrom
waterWang:fix/geo-preserve-d3-default-rotation
Open

fix(geo): preserve D3 projection default rotation when user does not set rotation#7956
waterWang wants to merge 1 commit into
plotly:masterfrom
waterWang:fix/geo-preserve-d3-default-rotation

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #7949

Problem

Geo.updateProjection unconditionally calls projection.rotate() which overwrites the D3 projection's built-in default rotation. Six projections in plotly.js carry a non-identity default rotation (e.g. peirce quincuncial [-90, -90, 45], wiechel [0, -90, 45]), and the unconditional override causes these to render in the wrong orientation.

Fix

Only call projection.rotate() when the user explicitly set rotation values in the layout input, or when fitbounds has derived a rotation from the data. Otherwise preserve the D3 projection's default rotation so that maps render in their canonical orientation.

Testing

  • Projections with non-identity defaults (peirce quincuncial, wiechel, etc.) now render in their canonical orientation when no rotation is specified
  • When the user explicitly sets projection.rotation, the supplied values are applied correctly
  • fitbounds mode continues to work as before (rotation is derived from data bounds)

…set rotation

Geo.updateProjection unconditionally called projection.rotate() which
overwrites the D3 projection's built-in default rotation. For projections
that ship with a non-identity default (e.g. peirce quincuncial [-90,-90,45],
wiechel [0,-90,45]), the map rendered in a different orientation.

Only call projection.rotate() when the user explicitly set rotation values
or when fitbounds has derived a rotation from the data. Otherwise preserve
the D3 projection's default rotation so maps render in their canonical
orientation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: geo projections lose their D3 default rotation

1 participant