[BUG]: `sankey`: `node.x` / `node.y` of `0` is ignored

未关闭 适合新手
#8,150 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@adimalkar 已经在做这个了。

开始于 2026年11月1日。

  • #8158 来自 @adimalkar —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
d3, javascript

调研方向

从 src/traces/sankey/render.js 中的“Force node position”循环开始,检查它如何判断 trace.node.x[p] 和 trace.node.y[p] 是否缺失。使用提供的 Plotly.newPlot 示例并设置 arrangement: 'fixed' 来复现问题。当值为 0 的坐标得到保留,且 mock 基准文件 sankey_x_y_with_arrows.json 按需更新后,即为完成。

由索引模型根据 Issue 内容生成。

描述

bug P3 size: 1
Description

Node coordinates of 0 for node.x or node.yare ignored and the node gets positioned automatically.

Screenshots

With 0 coords:

Image

With close to 0 coords:

Image
Steps to reproduce
  • Open Plotly devtools and paste the following into browser devtools:
Plotly.newPlot('g', [{
  type: 'sankey',
  arrangement: 'fixed',
  node: {label: ['a', 'b', 'c'], x: [0, 0.5, 0.8], y: [0, 0, 0.7]},
  link: {source: [0, 1], target: [1, 2], value: [1, 1]}
}], {margin: {l: 0, r: 0, t: 0, b: 0}});
  • Note that the center of a is not in the top left corner of the plot
Notes
  • This issue stems from the fact that the "Force node position" loop in src/traces/sankey/render.js uses a truthy test (if(trace.node.x[p] && trace.node.y[p])), and 0 is falsy
  • The fix is to change the test for missing values to != null
  • The mock sankey_x_y_with_arrows.json sets y: [0, 0, 0], so the fix changes its baseline
  • Discovered while working on #7826
主要语言
JavaScript
星标
18.4k
派生
2.1k
平均合并
1 天 5 小时
30 天内合并 PR
12

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

plotly/plotly.js 的其他 Issue

查看 plotly/plotly.js 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。