Skip to content

fix(layout): exclude Dagre endpoints from control points - #7687

Merged
hustcc merged 1 commit into
antvis:v5from
dvd233:codex/fix-dagre-control-points
Oct 16, 2026
Merged

hustcc merged 1 commit into
antvis:v5from
dvd233:codex/fix-dagre-control-points

Conversation

@dvd233

@dvd233 dvd233 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #7671.

Dagre includes node-boundary endpoints in edge.points. Passing these through as control points duplicates the rendered endpoints, leaving a zero-length end tangent and incorrect arrow orientation.

Exclude those endpoints only for Dagre, preserving AntVDagre/custom-layout output and the raw layout data. Add regressions for all four rank directions, missing/empty points, and input immutability.

Validation:

  • The four Dagre regressions fail before the fix and pass afterward.
  • Core Jest: 217 suites pass, 700 tests pass, 2 tests skipped by an existing it.only in camera-setting.spec.ts (Ubuntu, Node 22, native SWC). Changed statements and branches are fully covered.
  • Core ESLint, Prettier, TypeScript, CJS/ESM/UMD builds and bundle size checks pass (Windows, Node 20).
  • Chromium verifies aligned arrows and nonzero end tangents for all 12 edges across LR/RL/TB/BT, using the built UMD. The original example's unregistered drag-node warning remains; this probe covers the initial static layout.
Before (LR) After (LR)
Before After

@hustcc

hustcc commented Oct 13, 2026

Copy link
Copy Markdown
Member

@dvd233 是不是应该在 layout 库修复这个问题?

@dvd233

dvd233 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

我倾向于先在 G6 的适配层处理:Dagre 的 edge.points 表示包含节点边界端点的完整折线,而 G6 的 controlPoints 只应包含中间点,渲染时会自行补端点。直接传入会重复端点,导致末端切线为零;这不一定是 layout 的完整折线输出有误。这个补丁仅在 Dagre → G6 controlPoints 的转换中取 slice(1, -1),不修改原始 layout 结果,也不改变 AntVDagre/custom layout 的行为,避免影响其他直接消费完整 points 的调用方。四个方向的回归均已验证先失败后通过,浏览器里 12 条边的末端切线和箭头方向也已核对。这里的选择基于上述两层数据契约,最终修复位置请维护者确认。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fix matches endpoint rendering behavior, has focused regression coverage, and has no unresolved findings.

0 open findings

What changed in this PR

Fixes Dagre edge arrow orientation by excluding node-boundary endpoints from rendered control points, addressing #7671.

Changes:

  • Removes endpoints only for Dagre, preserving other layouts and raw layout data.
  • Adds regressions for all four rank directions, missing/empty points, and input immutability.
File Description
packages/​g6/​src/​utils/​layout.ts Excludes Dagre endpoints from control points.
packages/​g6/​__tests__/​unit/​utils/​layout.spec.ts Adds regression and compatibility coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (e825d09) to head (a1666a1).
⚠️ Report is 1 commits behind head on v5.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##               v5    #7687   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files         188      188           
  Lines       10099    10101    +2     
  Branches     2152     2153    +1     
=======================================
+ Hits         9537     9539    +2     
  Misses        516      516           
  Partials       46       46           
Flag Coverage Δ
g6 94.43% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/g6/src/utils/layout.ts 66.66% <100.00%> (+0.45%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hustcc
hustcc merged commit 9d592b7 into antvis:v5 Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: dagre布局,polyline类型的edge,endArrow方向反了

4 participants