synergycodes/ng-diagram/ng-diagram-edge-routing
Claude Code and agent skill by synergycodes/ng-diagram
- community
Checking that the SKILL.md file is still in the repository.
Use when shaping ng-diagram edge paths - orthogonal/bezier/polyline, routingMode auto vs manual, waypoints, edges not following nodes, custom routing (registerRouting), or "Edge routing ... is not registered", "Invalid edge coordinates detected".
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-edge-routingSKILL.md
Edge routing
How edge paths are computed: the built-in routings and their options, auto vs manual points, and custom routing algorithms. Layout engines (ELK, dagre) are in ng-diagram-auto-layout, edge looks in ng-diagram-custom-edges, free ends in ng-diagram-dangling-edges.
Rules
- There are three built-in routings:
'orthogonal'(the default),'bezier'and'polyline'. Set one per edge withedge.routing; edges without it use the default routing.edgeRouting.defaultRoutingis read once, when the diagram engine is created. Change it later withNgDiagramService.setDefaultRouting(name). routingMode: 'auto'(default): the library computespointson every routing pass, so your writes topointsare overwritten.routingMode: 'manual': you ownpoints. The library keeps them, draws them with the routing's SVG path and places labels on them. A manual edge withoutpointsis not drawn.sourcePositionandtargetPositionare computed from nodes and ports on every routing pass (also for manual edges) and areundefineduntil the ports are measured. The only exception is a free end of a dangling edge, where the position is your anchor.- An edge is routed again when its ends, ports,
routing,routingMode,pointsor labels change, or when a connected node moves, resizes, rotates or gets new port measurements. ChangingedgeRoutingoptions or the default routing does not re-route existing edges. - A custom routing is a class that implements
EdgeRouting. Register it withNgDiagramService.registerRouting()in the(diagramInit)handler. Before the engine exists, the services throw[ngDiagram] Library engine not initialized yet. Every new model creates a new engine without your routings, anddiagramInitfires again after it. - An unknown routing name never breaks an edge: the edge uses the default routing and a warning is logged.
Configure the built-in routings
| Option | Default | Effect | |
|---|---|---|---|
edgeRouting.defaultRouting | 'orthogonal' | Routing for edges without routing. | |
edgeRouting.orthogonal.firstLastSegmentLength | 20 | Straight part at each port. | |
edgeRouting.orthogonal.maxCornerRadius | 15 | Corner rounding; 0 gives sharp corners. | |
edgeRouting.bezier.bezierControlOffset | 100 | Distance of the curve's control points from the ends. |
Polyline in auto mode is a straight line between the two ends; in manual mode it connects your points with straight segments. The built-in routings look only at the two ends: they do not route around other nodes. For paths around nodes, use points from a layout engine (ng-diagram-auto-layout).
Change routing at runtime
To let a manual edge follow its nodes again, update it to routingMode: 'auto'; the next routing pass replaces its points. ng-diagram-auto-layout shows this pattern for edges placed by a layout engine.
Path computed in the edge template (follows the nodes)
<ng-diagram-base-edge> writes the routing, routingMode and points of the edge you pass into the model, so labels, relink handles and toJSON() use your points. Register the component in an edge template map (ng-diagram-custom-edges).
Custom routing algorithm
computePoints(context, config)getssourcePoint/targetPoint(withside), theedge, andsourceNode/targetNode/sourcePort/targetPortfor connected ends.computeSvgPath(points, config)gets the config too.configis the currentedgeRoutingconfig; put your options under your routing name.computePointOnPath(points, percentage)andcomputePointAtDistance(points, px)(the latter since 1.1.0) are optional and get only the points, not the config. Without them, relative labels sit on the straight line between the first and last point, and'Npx'labels follow the straight segments between your points (here: through the control point).- Edges of the initial model are routed before
diagramInit. With a routing that is not registered yet, they use the default routing and log a warning until their next routing pass. When the shape must be right from the first paint, leave those edges out ofinitializeModeland add them in thediagramInithandler right afterregisterRouting(), withawait modelService.addEdges(edges). - Other methods on
NgDiagramService:unregisterRouting(name),getRegisteredRoutings(),getDefaultRouting(). Registering an existing name replaces that routing, built-ins included.
Edge cases
- Dangling edges are routed between their anchors with any routing; the direction at a free end faces the other end.
- Effectively hidden edges are not routed; they are routed again when shown.
edgeRouting.defaultRoutingin the config is not checked. Set to a custom name that is not registered yet, edges withoutroutingget a straight two-point path that may draw as nothing. CallsetDefaultRouting()afterregisterRouting()instead: it checks the name.- Do not unregister the routing that is the default: edges without
routingare then left without a usable routing. - For manual-routing edges the library moves the matching end point of
pointson a relink,attachEdge,detachEdgeand a detach on node delete; paste moves all points (since 1.4.0).
Symptom → fix
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ng-diagram-edge-routing/SKILL.md
Popularity
- Repository stars
- 583
- Repository forks
- 41
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/synergycodes/ng-diagram/ng-diagram-edge-routing)