[BUG]: Automargin for quiver plots is a little off with `arrowref: 'paper'`
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
Desired behavior
Quiver automargin should always result in an initial plot area which contains all arrow endpoints.
Current behavior
The current quiver implementation calculates the arrow endpoints assuming arrowref: 'data', uses those endpoints to compute the automargin extents, and then if arrowref is 'paper'`, applies an adjustment factor to the arrow endpoints.
If the x:y aspect ratio of the data is pretty close to 1:1, this works OK because the arrow endpoints don't change much. But if the aspect ratio of the data is very far from 1:1, this can result in an initial plot where the arrow endpoints extend outside of the plotted area.
Example
Figure definition:
{
"data": [
{
"type": "quiver",
"uhoverformat": ".3f",
"yhoverformat": ".3f",
"xhoverfomrat": ".3f",
"vhoverformat": ".3f",
"x": [0],
"y": [0],
"u": [1],
"v": [0.1],
"arrowref": "paper"
}
],
"layout": {
"width": 800,
"height": 600,
"showlegend": false
}
}
Screenshot:
Notice how the tip of the arrow extends off the right side of the plot.
Fix
The relevant logic is around lines 200-206 in src/traces/quiver/calc.js.
It's a bit of a chicken-and-egg problem, because when arrowref is 'paper', the data position of the arrow endpoints depends on the axis scales, which depend on the position of the arrow endpoints. I think there is probably an algebraic solution but haven't quite been able to figure it out. Alternatively there's probably an iterative or approximate approach we could apply here that would still be an improvement over the current behavior.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 src/traces/quiver/calc.js 大约第 200-206 行开始,并将提供的 quiver 图形复现出来,同时将 arrowref 设置为 paper。跟踪箭头端点和 automargin 范围是如何相对于坐标轴刻度计算的。完成的标准是初始绘图区包含所有箭头端点,即使数据的宽高比与 1:1 有显著差异。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100