X6 Development
Goal
Help the user implement X6-based features quickly and correctly, with strong defaults
for graph initialization, interaction config, node/edge modeling, and plugin selection.
Primary References
Use these official references first:
When This Skill Triggers
Trigger on requests like:
- "做一个流程图编辑器 / DAG 编辑器"
- "X6 怎么配置画布缩放和拖拽"
- "节点、边、连接桩怎么设计"
- "需要找 X6 示例或 API"
- "实现小地图、框选、撤销重做、对齐线、模板面板"
Also trigger on Chinese phrasing variants:
- "画布缩放拖拽怎么配"
- "节点之间怎么限制连线"
- "给我找个 X6 示例照着改"
- "怎么做类似流程编排的编辑器"
- "怎么做图数据保存和回显"
Workflow
Follow this sequence unless the user asks otherwise:
- Clarify scenario and constraints:
- Scene type: flowchart, DAG, topology, ER, org chart.
- Interaction requirements: pan/zoom, connect rules, selection, keyboard.
- Scale: expected node/edge counts and performance constraints.
- Define graph bootstrapping options:
- Container lifecycle and resize behavior.
- Core options in
new Graph(options):
autoResize, panning, mousewheel, grid, background,
connecting, interacting, translating, async, virtual.
- Design data model:
- Node schema:
id, shape, position, size, data, ports.
- Edge schema:
source, target, labels, router, connector.
- Pick extension strategy from examples:
- Plugins and built-ins: minimap, stencil, selection, clipboard,
keyboard, snapline, transform, history, scroller, export.
- Implement incrementally:
- First render base graph.
- Then add interactions and plugins.
- Finally add custom nodes/ports/events and persistence.
- Verify:
- Canvas interactions, connection constraints, serialization/deserialization.
- Edge cases: invalid connections, zoom bounds, large graph behavior.
Implementation Checklist
Before finishing, ensure:
- Graph instance is created and disposed cleanly with component lifecycle.
autoResize and container sizing are correct.
panning and mousewheel behavior matches UX expectations.
- Node/edge defaults are centralized (style, router, connector, markers).
- Connection validation (
connecting.validateConnection) exists for business rules.
- Event handlers are scoped and cleaned up to avoid leaks.
- Data persistence path is clear (
graph.toJSON() and restore flow).
Fast API Lookup Playbook
When user asks "how to configure X6":
- Map question to API area:
- Canvas/global behavior -> Graph options.
- Node/edge visuals -> shape/attrs/tools/labels.
- Interaction constraints ->
interacting, connecting, translating.
- Provide a minimal runnable snippet first.
- Add one advanced option only when needed (avoid over-configuring).
- Link a matching official example category for rapid follow-up.
Output Style
For implementation requests, return:
- A short architecture choice statement.
- A minimal code scaffold.
- Optional enhancements in priority order.
- Validation or test steps.
For troubleshooting requests, return:
- Most likely root cause.
- Smallest fix.
- One prevention pattern for future regressions.
Guardrails
- Prefer official API and examples over unofficial snippets.
- Avoid introducing many plugins at once; add progressively.
- Keep configuration explicit and close to graph initialization.
- Use stable IDs and deterministic serialization to reduce merge conflicts.
X6 Chinese Quick Recipes
Use these snippets/patterns when user asks for "直接可用方案".
1) Restrict invalid connections
Intent: prevent illegal source/target links.
Pattern:
- Configure
connecting.validateConnection(args) at graph creation.
- Reject same-node loops unless explicitly needed.
- Validate port group compatibility (
out -> in).
- Optionally reject duplicate edges.
2) Port groups for maintainable node IO
Intent: keep node ports consistent across shapes.
Pattern:
- Define reusable port groups (
in, out) with shared attrs/position.
- Add business-level metadata in
port.data (signal type, capacity).
- Enforce rules in
validateConnection using that metadata.
3) Persistence and restore flow
Intent: save and recover editor state reliably.
Pattern:
- Save via
graph.toJSON() with stable id.
- Restore with
graph.fromJSON(json) after base graph is ready.
- Store app-specific metadata in
cell.data, avoid deriving from style attrs.
- Version persisted schema when structure changes.
4) Large graph performance defaults
Intent: improve interaction smoothness for high node counts.
Pattern:
- Enable
async rendering.
- Consider
virtual rendering for viewport-only draw.
- Reduce expensive decorations (shadows/filters/tools shown by default).
- Batch updates where possible instead of many tiny mutations.
5) Recommended plugin rollout order
Intent: avoid complexity spikes.
Order:
- selection + keyboard
- snapline + transform
- history + clipboard
- minimap + stencil
Add the next layer only after current interactions are stable.
1---2name: x6-development3description: Build, review, and troubleshoot X6 graph editor features. Strongly trigger this skill whenever the user mentions X6/AntV X6 or related Chinese intents such as 流程图编辑器、DAG 编辑器、节点编排、节点连线、连接桩、端口、路由、自动布局、小地图、框选、撤销重做、Stencil/模板面板、X6 API 查询、X6 示例检索, even when the user does not explicitly ask for a skill.4---56# X6 Development78## Goal910Help the user implement X6-based features quickly and correctly, with strong defaults11for graph initialization, interaction config, node/edge modeling, and plugin selection.1213## Primary References1415Use these official references first:1617- About: https://x6.antv.antgroup.com/tutorial/about18- Graph API: https://x6.antv.antgroup.com/api/graph/graph19- Examples: https://x6.antv.antgroup.com/examples2021## When This Skill Triggers2223Trigger on requests like:2425- "做一个流程图编辑器 / DAG 编辑器"26- "X6 怎么配置画布缩放和拖拽"27- "节点、边、连接桩怎么设计"28- "需要找 X6 示例或 API"29- "实现小地图、框选、撤销重做、对齐线、模板面板"3031Also trigger on Chinese phrasing variants:3233- "画布缩放拖拽怎么配"34- "节点之间怎么限制连线"35- "给我找个 X6 示例照着改"36- "怎么做类似流程编排的编辑器"37- "怎么做图数据保存和回显"3839## Workflow4041Follow this sequence unless the user asks otherwise:42431. Clarify scenario and constraints:44 - Scene type: flowchart, DAG, topology, ER, org chart.45 - Interaction requirements: pan/zoom, connect rules, selection, keyboard.46 - Scale: expected node/edge counts and performance constraints.472. Define graph bootstrapping options:48 - Container lifecycle and resize behavior.49 - Core options in `new Graph(options)`:50 `autoResize`, `panning`, `mousewheel`, `grid`, `background`,51 `connecting`, `interacting`, `translating`, `async`, `virtual`.523. Design data model:53 - Node schema: `id`, `shape`, `position`, `size`, `data`, `ports`.54 - Edge schema: `source`, `target`, `labels`, `router`, `connector`.554. Pick extension strategy from examples:56 - Plugins and built-ins: minimap, stencil, selection, clipboard,57 keyboard, snapline, transform, history, scroller, export.585. Implement incrementally:59 - First render base graph.60 - Then add interactions and plugins.61 - Finally add custom nodes/ports/events and persistence.626. Verify:63 - Canvas interactions, connection constraints, serialization/deserialization.64 - Edge cases: invalid connections, zoom bounds, large graph behavior.6566## Implementation Checklist6768Before finishing, ensure:6970- Graph instance is created and disposed cleanly with component lifecycle.71- `autoResize` and container sizing are correct.72- `panning` and `mousewheel` behavior matches UX expectations.73- Node/edge defaults are centralized (style, router, connector, markers).74- Connection validation (`connecting.validateConnection`) exists for business rules.75- Event handlers are scoped and cleaned up to avoid leaks.76- Data persistence path is clear (`graph.toJSON()` and restore flow).7778## Fast API Lookup Playbook7980When user asks "how to configure X6":81821. Map question to API area:83 - Canvas/global behavior -> Graph options.84 - Node/edge visuals -> shape/attrs/tools/labels.85 - Interaction constraints -> `interacting`, `connecting`, `translating`.862. Provide a minimal runnable snippet first.873. Add one advanced option only when needed (avoid over-configuring).884. Link a matching official example category for rapid follow-up.8990## Output Style9192For implementation requests, return:93941. A short architecture choice statement.952. A minimal code scaffold.963. Optional enhancements in priority order.974. Validation or test steps.9899For troubleshooting requests, return:1001011. Most likely root cause.1022. Smallest fix.1033. One prevention pattern for future regressions.104105## Guardrails106107- Prefer official API and examples over unofficial snippets.108- Avoid introducing many plugins at once; add progressively.109- Keep configuration explicit and close to graph initialization.110- Use stable IDs and deterministic serialization to reduce merge conflicts.111112## X6 Chinese Quick Recipes113114Use these snippets/patterns when user asks for "直接可用方案".115116### 1) Restrict invalid connections117118Intent: prevent illegal source/target links.119120Pattern:121122- Configure `connecting.validateConnection(args)` at graph creation.123- Reject same-node loops unless explicitly needed.124- Validate port group compatibility (`out` -> `in`).125- Optionally reject duplicate edges.126127### 2) Port groups for maintainable node IO128129Intent: keep node ports consistent across shapes.130131Pattern:132133- Define reusable port groups (`in`, `out`) with shared attrs/position.134- Add business-level metadata in `port.data` (signal type, capacity).135- Enforce rules in `validateConnection` using that metadata.136137### 3) Persistence and restore flow138139Intent: save and recover editor state reliably.140141Pattern:142143- Save via `graph.toJSON()` with stable `id`.144- Restore with `graph.fromJSON(json)` after base graph is ready.145- Store app-specific metadata in `cell.data`, avoid deriving from style attrs.146- Version persisted schema when structure changes.147148### 4) Large graph performance defaults149150Intent: improve interaction smoothness for high node counts.151152Pattern:153154- Enable `async` rendering.155- Consider `virtual` rendering for viewport-only draw.156- Reduce expensive decorations (shadows/filters/tools shown by default).157- Batch updates where possible instead of many tiny mutations.158159### 5) Recommended plugin rollout order160161Intent: avoid complexity spikes.162163Order:1641651. selection + keyboard1662. snapline + transform1673. history + clipboard1684. minimap + stencil169170Add the next layer only after current interactions are stable.