[BUG]: geo projections lose their D3 default rotation
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
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 |
|---|---|
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Geo.updateProjection 开始,将其旋转处理方式与 D3 投影构造函数进行比较,尤其是 issue 中描述的 quincuncial 和 wiechel 默认值。在浏览器中复现 peirce quincuncial 示例,然后验证渲染出的方向在应用请求的旋转的同时,仍保留投影的规范默认值。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 72/100