[BUG]: geo projections lose their D3 default rotation

オープン
#7,949 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript

調査の方向性

Geo.updateProjection から始め、回転の処理を D3 の投影コンストラクターと比較します。特に、issue で説明されている quincuncial と wiechel のデフォルトを確認してください。ブラウザーで peirce quincuncial の例を再現し、レンダリングされた向きが投影の正規のデフォルトを維持しながら、要求された回転も適用していることを検証します。

索引モデルが issue の本文から書いたものです。

説明

bug P3 plotly-internal size: 3
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.
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
28

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/plotly.js のほかの issue

plotly/plotly.js の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。