You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where two edges cross, the one that gives way is drawn with a small arc
(or a gap) so it is clear which line passes over which. On by default;
`elk.lineHops: false` for plain crossings, `'gap'` for gaps.
Detection and both styles already existed for swimlanes. What is new is
the `afterPaint` hook that lets ELK use them, and `applyLineJumpsToSvg`
being exported so a layout package outside `mermaid` can reach it.
Two defects in the hop geometry are fixed here, both found on real
diagrams and both of which rendered as something that looked broken
rather than merely untidy:
- A hop with no room next to a bend was fitted into whatever was left,
as little as 2.9px against a requested 6, opening exactly on the
corner's tangent point. At that radius the arc does not clear the
stroke it is hopping, so the lines still touch. Hops now keep a
straight run clear of the bend, and one that would still shrink below
60% of the requested radius is dropped — an ordinary crossing is a
much better failure than a broken-looking hop.
- A crossing found inside the stretch where either edge is rounding a
bend is now ignored. Crossings are computed on polylines, but a
rounded edge is not drawn as its polyline: it leaves the line up to
7.07px before each bend and rejoins it that far after. A crossing
found in there is somewhere the stroke never goes, so the arc arched
over blank paper while the two lines carried on touching beside it.
feat: draw line hops where ELK edges cross, controlled by `elk.lineHops`.
6
+
7
+
Where two edges cross, the one that gives way is drawn with a small arc (or a visible gap) so it is clear which line passes over which. On by default; set `elk.lineHops: false` to draw plain crossings, or `'gap'` to use gaps instead of arcs.
8
+
9
+
```yaml
10
+
---
11
+
config:
12
+
layout: elk
13
+
elk:
14
+
lineHops: gap
15
+
---
16
+
```
17
+
18
+
The crossing detection and both styles already existed and were used by swimlanes — this registers the `afterPaint` hook that lets ELK use them. An edge that takes a hop loses its corner rounding on that segment, which is the trade for a readable crossing; curved edges are skipped rather than rewritten, to avoid corrupting their geometry.
19
+
20
+
**Existing ELK diagrams with crossing edges will render differently.**
feat: export `applyLineJumpsToSvg` so layout packages outside this one can draw line hops.
6
+
7
+
Line jumps are applied after paint, once every edge has been emitted and the crossings are known. A layout that ships inside this package can reach into `rendering-util` to do that; one that ships separately, like `@mermaid-js/layout-elk`, cannot. Exporting it alongside the other common-renderer pieces lets an external layout register an `afterPaint` hook that draws hops the same way the built-in ones do.
8
+
9
+
`EdgeGeom` and `LineJumpConfig` are exported with it, since they are the argument types.
fix: don't draw a line hop that has no room next to a bend.
6
+
7
+
A crossing close to a corner used to get a hop squeezed into whatever space was left — as little as 2.9px against a requested 6px, opening exactly on the corner's tangent point. At that size the arc no longer clears the line it is meant to hop, so the two strokes still touch and the corner's curve runs straight into the arc's. It reads as a rendering fault rather than as a crossing.
8
+
9
+
Hops now keep a straight run clear of the bend, and one that would still have to shrink below 60% of the requested radius is dropped instead of drawn. An undrawn hop is an ordinary crossing, which is a much better failure than a broken-looking one.
10
+
11
+
This shows up wherever a layout stacks edges in narrow lanes: ELK routes subgraph-internal edges 10px apart, and 10px does not hold a 7.07px corner cut plus a 6px hop.
12
+
13
+
A crossing is also ignored now when it lands inside the stretch where either edge is rounding a bend. Crossings are found on polylines, but a rounded edge is not drawn as its polyline — it leaves the line up to 7.07px before each bend and rejoins it that far after. A crossing found inside that stretch is somewhere the stroke never goes, so the hop was arching over blank paper while the two lines carried on touching beside it.
0 commit comments