Skip to content

Feature request: line jumps (hops) where connections cross #3005

Closed

Description

@pjpscriv

Summary

When two connections cross, D2 draws them straight through each other. In a busy diagrams it can sometimes be you hard to tell whether two lines cross or meet, adding a follow a connection to its end.

Many diagramming tools (draw.io, Visio, Lucidchart, PlantUML via skinparam) solve this with line jumps: at each crossing, one of the lines draws a small arc (a "hop") or a gap over the other.

It would be really cool if D2 could support this as an option.

Minimal example

a -> x
a -> y
b -> x
b -> y

With two sources each connected to both targets, any layered layout has to cross two of the connections.

Rendered with d2 --layout=elk crossing.d2 (D2 v0.9.0):

crossing-elk

The a -> y and b -> x connections cross in the middle, with nothing to show that they don't join there. Dagre (the default) has the same crossing:

crossing-dagre

Proposed behaviour

At each point where two connections cross, draw a small semicircular hop (or a gap) in one of them. Here is the Dagre example above, mocked up in diagrams.net to show the expected result:

expected-3 drawio

This would be off by default and enabled through config, for example:

vars: {
  d2-config: {
    line-jumps: arc   # none (default) | arc | gap
  }
}

or a CLI flag (--line-jumps=arc), or a per-connection style.line-jump.

Possible details:

  • Which line hops: a consistent rule, such as horizontal lines hop over vertical lines, or the connection declared later hops over the earlier one. This is how draw.io and Visio handle it.
  • Size: a fixed radius relative to the stroke width, possibly configurable.
  • Scope: crossings between connections only. Connections passing behind shapes don't need it.

Motivation

  • Large architecture and network diagrams often can't avoid crossings, even with ELK or TALA.
  • Line jumps are a familiar convention in engineering, electrical and network diagrams.
  • Because they're applied after layout (a rendering step on the final connection paths), they should work the same with every layout engine.

Disclosure: I used Claude to help draft this issue, but reviewed the content and the example diagrams myself before submitting.

Activity

  1. alixander commented on Nov 23, 2026

    @alixander
    Collaborator

    Thanks for the four-edge example. We implemented the gap variant in #3011. It works by default with ELK and Dagre and will be in the next D2 release.

    At the red X in this SVG, the connection from g to a stays continuous. The connection from b to d has a small gap where they cross.

    D2 diagram showing a gap in the red connection from b to d where it crosses the continuous red connection from g to a.

    • sent from alixander's Codex
  2. pjpscriv commented on Nov 24, 2026

    @pjpscriv
    Author

    @alixander ah excellent good to know! Looking forward to using it :)

    I suppose there's an extension that could be made here for adding the arc-type jump as well as the gap-type one, but if I find myself burning with desire for that I can open a fresh issue 👍

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions