terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
16.61k stars 417 forks source link

adjust edge spacing/minimum length #1214

Open gavin-ts opened 1 year ago

gavin-ts commented 1 year ago

should consider edge label dimensions, source/target arrowheads (and labels) to adjust how far apart edges need to be from each other, and how long they must be at a minimum

dagre and elk will need to be configured accordingly, dagre will likely need this to be set globally (max of all edges), but maybe elk can do this per-edge

alixander commented 1 year ago

do you have an example d2? @gavin-ts

gavin-ts commented 1 year ago

Here's an example, it should adjust min edge length according to all of these factors

direction: right

0: no label {
  x -> y
}

1: label {
  x -> y: 1234567890
}

2: arrowhead label {
  a -> b: {
    target-arrowhead: 1234567890
  }
}

3: large arrowhead {
  a -> b: {
    target-arrowhead.shape: diamond
    style.stroke-width: 10
  }
}

Screen Shot 2023-04-27 at 7 30 07 PM

https://play.d2lang.com/?script=gkevlUIRKDi5uAysFPLyFcABp1DNpaBQoaBrp1DJVcvFZWiFIWylYGhkbGJqZm5haQBSYmSlAHcjkuJEkOIkKzBbQQHdMyiGKCjUggwyBtlVlJ6KZBxhg_TAkWSlkJKZmJuflwJWAw5OPeRQtlIwhFkDCAAA__8%3D&layout=elk&