[AntVDagreLayout] ranksep 未透传给 dagre 内核,导致层间距计算与 nodesep 不一致,想确认是否属于设计如此
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- data-visualization
Direzione di ricerca
The padding uses ranksep in src/algorithm/antv-dagre/index.ts (height = size[1] + 2 * vertisep), but the call to the dagre kernel layout(g, {...}) passes only nodesep. Run the reproduction script for edgeLabelSpace true and false with ranksep 50 and 200 to confirm the layer spacing values in the table. Before changing code, the maintainers must decide whether omitting ranksep was intentional. If they agree it is a bug, done means passing ranksep to the kernel and getting the 160/610/160/610 spacings.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
版本
@antv/layout2.0.1(npmbeta),在v5分支最新代码(62bb479)上同样可复现- 对照版本:
@antv/layout0.3.25 的DagreLayout
现象
在 AntVDagreLayout 中,ranksep 仅被用作节点的上下 padding(src/algorithm/antv-dagre/index.ts 中 height = size[1] + 2 * vertisep)。而在调用底层 dagre 内核的 layout(g, {...}) 时,并没有传入 ranksep(只传了 nodesep)。
这就导致内核在缺少 ranksep 时,实际走了以下兜底处理:
edgeLabelSpace: true(默认):makeSpaceForEdgeLabels内部直接将未传入的ranksep视为 0,因此内核贡献的层间距为 0;edgeLabelSpace: false:内核直接使用了内置的默认值 50,用户配置的ranksep完全不生效。
对比来看,水平方向的 nodesep 既参与了 padding 扩充,又正常透传给了内核,因此同层间距与层间距的计算逻辑产生了分歧。
复现
const { AntVDagreLayout } = require('@antv/layout');
const data = {
nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
edges: [
{ id: 'e1', source: 'a', target: 'b' },
{ id: 'e2', source: 'a', target: 'c' },
],
};
(async () => {
for (const edgeLabelSpace of [true, false]) {
for (const ranksep of [50, 200]) {
const layout = new AntVDagreLayout({ nodeSize: 10, ranksep, edgeLabelSpace });
await layout.execute(data);
const pos = {};
layout.forEachNode((node) => (pos[node.id] = node));
// 相邻层中心距离 (Δy) / 同层中心距离 (Δx)
console.log(edgeLabelSpace, ranksep, pos.b.y - pos.a.y, pos.c.x - pos.b.x);
}
}
})();
实测结果(nodeSize: 10,nodesep 取默认值 50,测量值为节点中心距):
edgeLabelSpace |
ranksep |
2.0.1 层间距 (Δy) | 0.3.25 层间距 (Δy) | 同层间距 (Δx,两版本相同) |
|---|---|---|---|---|
true |
50 | 110 | 160 | 160 |
true |
200 | 410 | 610 | 160 |
false |
50 | 160 | 160 | 160 |
false |
200 | 460 | 610 | 160 |
间距公式拆解:
- 2.0.1 层间距:
nodeSize + 2 × ranksep + 内核间距(edgeLabelSpace: true时内核间距为 0;false时固定为 50) - 0.3.25 层间距:
nodeSize + 2 × ranksep + 1 × ranksep = nodeSize + 3 × ranksep(与edgeLabelSpace无关) - 同层间距(两版本一致):
nodeSize + 2 × nodesep + 1 × nodesep = nodeSize + 3 × nodesep
想确认的问题
-
不给内核传
ranksep是特意这样设计的,还是属于遗漏?
如果是特意设计的,那么在edgeLabelSpace: false时因内核默认值而固定多出来的 50px 间距,是否也符合预期? -
如果属于遗漏,是否方便统一修复?
若在调用内核时补齐ranksep参数:- 上述四种场景的层间距将统一为
160 / 610 / 160 / 610,与 0.3.25 保持一致,同层间距与层间距的公式也能完全对齐; - 不过需要注意的是,在默认配置(
edgeLabelSpace: true)下,现有用户的实际层间距会普遍增大一个ranksep(默认参数下由nodeSize + 100变为nodeSize + 150)。
- 上述四种场景的层间距将统一为
想了解一下维护团队对该改动的看法。如果大家赞同这种对齐方案,我可以提个 PR 协助修复。
- Lingua principale
- TypeScript
- Stelle
- 279
- Fork
- 62
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di antvis/layout
-
D3ForceLayout: 配置的 center / centerX / x / y / radial 坐标及 radius 参数被默认值覆盖失效Forse già presa @chilingling l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
layout-gpu
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Tutte le issue di antvis/layout
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
grafana/profiles-drilldown#1212 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
grafana/traces-drilldown#980 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openremote/openremote#3487 · 1 commento ·
-
triage:needs-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
garrytan/gbrain#7635 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
coollabsio/jean#867 ·
I maintainer di solito rispondono entro 1 giorno