Skip to content

feat(v3): add chord chart component (#3893) - #3906

Closed
DoubleCore wants to merge 4 commits into
antvis:oss-camp2026from
DoubleCore:issue-3893-chord
Closed

DoubleCore wants to merge 4 commits into
antvis:oss-camp2026from
DoubleCore:issue-3893-chord

Conversation

@DoubleCore

Copy link
Copy Markdown

What this adds

charts/chord.md — 和弦图选型、矩阵/流向数据要求、常见变体与完整案例
examples/chord/ — 5 个可运行示例(基础、双向、自定义样式、深色主题、带 tooltip)
evals/cases/chord.jsonl — 17 条代表性评测用例(每行 1 个 JSON 对象)
skills/g2plot-v3/SKILL.md — 选型决策树新增 chord 入口
README.md / README.zh-CN.md — 图表支持列表

Checks

$ npm run validate   # tsc --noEmit
exit 0

$ npm run lint       # lint-md "**/*.md"
⌛️Done in 253ms.
exit 0

Scope

  • 只新增 chord 一种图表,未改动其他既有图表文档或示例
  • 示例使用 @antv/g2 v5 Spec API + new Chart({ container, autoFit: true }) + chart.render()
  • 矩阵数据自包含(source/target/value),演示双向流量与强度编码
  • 文档补充了 tooltip 配置与易错点(自环、数值全 0、对称矩阵误读)
  • 未修改 eval 框架、未新增运行时 npm 包

Closes part of #3893

Signed-off-by: DoubleCore <doublecore@users.noreply.github.com>
Signed-off-by: DoubleCore <doublecore@users.noreply.github.com>
Remove shared README and skill entry changes as requested by the maintainer; shared entries will be added by a separate batch PR.
Restore shared files to this PR's merge-base content, preserving upstream changes made after the branch diverged. A unified follow-up PR will own the batch entries.
@DoubleCore

Copy link
Copy Markdown
Author

按维护者 @interstellarmt 在 #3893 的协调结论,我保留已 review 的 8 个 PR(#3895/#3897/#3898/#3899/#3900/#3901/#3903/#3905),其余子任务交给其他同学认领,本 PR 关闭让位、不再推进。

交付物完整保留在分支 issue-3893-chord(charts/chord.md、examples/chord/*.ts、evals/cases/chord.jsonl,当前 MERGEABLE、仅含该图表自身文件),如后续需要对比实现或择优参考可直接查看;若新认领方需要放弃,我方可以重新接手。

给其他同学让路,避免重复开发。感谢 @interstellarmt 的协调。

@DoubleCore DoubleCore closed this Nov 19, 2026
@DoubleCore

Copy link
Copy Markdown
Author

给后来人的实现笔记(本 PR 已关闭让位,内容保留供参考)

这张图我实现过一版,按维护者协调已关闭让位给其他同学。把踩过的坑整理在这里,省得后来人重新试错。

关键路径

type: 'chord' 在该版本可用的独立 mark,不用自己拼 edge。

chart.options({
  type: 'chord',
  data: { value: { links } },                       // 注意多包一层 value
  encode: { source: 'from', target: 'to', value: 'migrants' },
});

节点由边自动推导,不需要单独提供 nodes;边的三个字段名任意,但必须在 encode 里显式映射。

高频易错点(都是我实际撞过的)

❌ 错误(幻觉高发) ✅ 正确
.source('from').target('to').weight('value')(v4 链式) encode: { source: 'from', target: 'to', value: 'value' }
new Chord('container', { sourceField, targetField, weightField })(G2Plot v2) new Chart({ container }) + type: 'chord'
data: { links }(缺外层 value,数据进不了 connector,图表空白) data: { value: { links } }
边字段叫 from / to 却没配 encode(默认只找 source / target,节点变成 undefined) encode: { source: 'from', target: 'to' }
用 chord 画单向分层流转(A → B → C) 用 type: 'sankey' 桑基图

完整表格见 charts/chord.md 的「易错点」章节。

交付物清单(对照 #3893 验收标准)

项 内容
文档 charts/chord.md,8 章齐全:何时使用 / 何时不用 / 数据要求 / 基础实现 / 常见变体 / 样式自定义 / 易错点 / 完整案例
示例 examples/chord/*.ts × 5,G2 v5 Spec API、数据自包含、头部块注释
评测 evals/cases/chord.jsonl × 17 条(≥10 已满足)
检查 npm run validate、npm run lint 通过

我做过什么(可直接复用)

分支 issue-3893-chord 保留完整实现,当前 MERGEABLE,只含本图表自身文件(不碰 README / SKILL.md):

git fetch origin issue-3893-chord
git checkout -b my-chord origin/issue-3893-chord     # 直接接手
# 或只取文件
git show origin/issue-3893-chord:charts/chord.md
git show origin/issue-3893-chord:evals/cases/chord.jsonl

重写时不必照抄,但建议:

  1. npm run validate + npm run lint 先跑通;
  2. 用 evals/cases/chord.jsonl 的 17 条用例反向验自己的实现,边界都写在里面;
  3. 文档完整代码块要与 examples/chord/basic.ts 逐字一致——这是维护者 review 的重点项。

实现上发现我哪里写错了,欢迎直接指出,我关了 PR 但代码还在。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 特性需求

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant