plotly / plotly/plotly.js

[BUG]: geo projections lose their D3 default rotation

Abierto
#7,949 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug P3 plotly-internal size: 3
Lenguaje dominante
JavaScript
Estrellas
18.3k
Forks
2k
Merge medio
2 d 12 h
PR fusionados (30 d)
28

Descripción

Description

Geo.updateProjection calls projection.rotate([-rotation.lon, -rotation.lat, rotation.roll]) unconditionally. For a world-scope map projection.rotation defaults to [0, 0, 0], so any rotation the D3 projection ships with is discarded.

Six of the projections in plotly.js carry a non-identity default rotation:

projection D3 default rotation
albers [96, 0, 0]
bertin1953 [-16.5, -42, 0]
gringorten quincuncial [-90, -90, 45]
peirce quincuncial [-90, -90, 45]
sinu mollweide [-20, -55, 0]
wiechel [0, -90, 45]

For the quincuncials and wiechel that rotation is geometric: it places the sphere in the polar aspect and tilts the square 45°, and is applied inside the projection's own constructor:

// d3-geo-projection/src/quincuncial/index.js
return projection(projectQuincuncial)
    .rotate([-90, -90, 45])
    .clipAngle(180 - 1e-3);

Replacing it renders a different orientation from the one D3 defines. (For albers, D3's [96, 0, 0] preconfigures it for the USA, so discarding it is probably intended.)

Screenshots/Video

For 'peirce quincuncial':

D3 projection Plotly projection
Image Image
Steps to reproduce
  • Be on master
  • Open Plotly devtools
  • Enter the following snippet into the browser console:
Plotly.newPlot(gd, [{
    type: 'choropleth',
    locations: ['GHA', 'ARG', 'AUS', 'CAN'],
    z: [1, 2, 3, 4],
    showscale: false
}], {
    geo: { projection: { type: 'peirce quincuncial' }, fitbounds: false },
    height: 800
});
  • Note that
  • Expected: the canonical peirce quincuncial orientation.
  • Actual: rendered with rotation [0, 0, 0].
Screenshots
Notes
  • A fix needs to compose the requested rotation onto each projection's default rather than replace it, since d3.geoProjection.rotate() replaces
  • This was discovered in #7948. It's possible that this is intentional for a good reason, but it would be worth looking at changing it regardless.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en Geo.updateProjection y compara el manejo de la rotación con los constructores de proyecciones de D3, especialmente los valores predeterminados de quincuncial y wiechel descritos en el issue. Reproduce el ejemplo de peirce quincuncial en el navegador y, después, verifica que la orientación renderizada conserve el valor predeterminado canónico de la proyección y aplique al mismo tiempo una rotación solicitada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
data-visualization
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
72/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.