Flowcharts: linkStyle interpolation
简介 / Introduction
The connectors in a flowchart are the most overlooked and most semantically loaded part of the drawing: when the happy path, the error path and the audit path all look the same, readers have to parse labels to figure out which is which. Mermaid styles an individual edge with the linkStyle statement, addressed by index; PlantUML instead inlines the color and line style directly on the arrow. There is a subtler difference too — whether an edge is drawn straight, as a polyline, or as a smooth curve is decided by the interpolation mode, and in Mermaid that switch lives in the %%{init:...}%% directive, entirely separate from linkStyle. This post walks through both approaches with the same request-validation flow.
PlantUML 版
1 | @startuml |
Key syntax notes:
skinparam ArrowColor/skinparam ArrowThickness— set the baseline color and width for every arrow; the scope is global-[#d33,bold]->— inline styling on the arrow itself.#d33is a hex color, andboldthickens the line (the rendered output showsstroke-width:2)-[#999,dashed]->— a dashed line. PlantUML supportsdashed(renders asstroke-dasharray:7,7) anddotted(stroke-dasharray:1,3)- Important: PlantUML does not accept
thickness=2. Using it returns an HTTP 400 syntax error;boldis the only thickness knob available - The color in the bracket is a completely separate mechanism from the node color suffix
<<#RRGGBB>>— the two never interact
PlantUML’s model is “style travels with the edge”: each style sits right next to the arrow it applies to. There is no index, and therefore no risk of an off-by-one.
Mermaid 版
1 | %%{init: {"flowchart": {"curve": "linear"}}}%% |
Key syntax notes:
linkStyle <index> <properties>— styles one edge by its declaration order, counted from 0. There are five edges here:A→B(0),B→C(1),B→D(2),C→E(3),D→F(4)- Supported properties:
stroke(color),stroke-width(thickness),stroke-dasharray(dash spacing, e.g.5 5) linkStylecan only target an edge that already exists. An out-of-range index fails hard:The index 4 for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and 3.%%{init: {"flowchart": {"curve": "linear"}}}%%— this is the global curve interpolation switch and has nothing to do withlinkStyle.curveacceptsbasis(the default, smooth spline),linear(polyline),monotoneXand others- The same setting can be written as YAML front matter:
---\nconfig:\n flowchart:\n curve: linear\n---
One trap worth remembering: interpolate is not a valid linkStyle property. Writing linkStyle 3 stroke:#999,interpolate:linear fails with Expecting 'SPACE', 'COLON', ... got 'INTERPOLATE'. Curve interpolation can only be set globally, via the init directive or the front matter — never per edge.
对比 / Side-by-side
| Meaning | PlantUML | Mermaid |
|---|---|---|
| Color one edge | -[#d33]-> inline on the arrow |
linkStyle 2 stroke:#d33 |
| How an edge is addressed | Inline syntax, no index needed | Zero-based index in declaration order |
| Dashed line | -[#999,dashed]-> |
linkStyle 2 stroke-dasharray:5 5 |
| Thicker line | -[#d33,bold]-> (one fixed step) |
stroke-width:2px (any value) |
| Global arrow baseline | skinparam ArrowColor / ArrowThickness |
No dedicated statement; use classDef or themeVariables |
| Curve interpolation | No equivalent — polylines only | %%{init: {"flowchart": {"curve": "linear"}}}%%, diagram-wide |
| What a mistake costs | Syntax error, HTTP 400 | Out-of-range index or unknown property — rendering fails outright |
小结 / Wrap-up
The division of labor is actually clean. PlantUML attaches styling to the edge itself, so a style can never drift onto the wrong arrow; Mermaid keeps styling in a separate global linkStyle list, which is easier to maintain centrally but leaves you responsible for counting edges. When working on Mermaid connectors, treat the linkStyle index and the curve interpolation setting as two unrelated concepts — the first controls color and thickness, the second controls geometry. Blurring them together is exactly how you end up with interpolate being rejected as an invalid property.
- Title: Flowcharts: linkStyle interpolation
- Author: puml.online
- Created at : 2026-11-11 09:00:00
- Updated at : 2026-11-26 01:07:01
- Link: https://puml.online/blog/flowchart-link-style-interpolate-en/
- License: This work is licensed under CC BY-NC-SA 4.0.