terrastruct / d2

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

More spacing options for ELK output #1221

Open martinber opened 1 year ago

martinber commented 1 year ago

I'm working with very large diagrams in the ELK layout and I would like to be able to reduce the spacing between the blocks and between the lines.

Running d2 layout elk I see that it is possible to set some parameters:

      --elk-algorithm string              layout algorithm (default "layered")
      --elk-nodeNodeBetweenLayers int     the spacing to be preserved between any pair of nodes of two adjacent layers (default 70)
      --elk-padding string                the padding to be left to a parent element’s border when placing child elements (default "[top=50,left=50,bottom=50,right=50]")
      --elk-edgeNodeBetweenLayers int     the spacing to be preserved between nodes and edges that are routed next to the node’s layer (default 40)
      --elk-nodeSelfLoop int              spacing to be preserved between a node and its self loops (default 50)

But I see that ELK has A LOT of extra options unavailable from d2 and I would like to try them. At least I would like to change the port spacing back to what we had in earlier versions

Do I have a way to change these things without forking d2 and editing the hardcoded values? It would be nice to be able to tweak all the parameters present in the documentation

Thank you

alixander commented 1 year ago

hey @martinber, yeah ELK has so many options that the creator/maintainers themselves have to look up the references to see what's out there. it's also quite confusing at times, where you are going for one effect, and multiple options are named such that they seem like they'll solve your problem. and some options depend on the existence of others in such a way that is unclear.

our goal is to not expose that in D2. we want to distill it to a small set that are impactful. So I'm against opening up the floodgates to all ELK parameters.

But if you have any specific ones you'd like to see, I'm happy to investigate and add to D2.

martinber commented 1 year ago

Thanks for the answer.

I would like to reduce the spacing in diagrams like the on the picture below. In my case I tend to have blocks like x that has arrows going to almost every block downstream. The biggest problem seems to be the spacing between lines and the spacing between the ports of x. The spacings should be as small as possible because I have hundreds of nodes

imagen

And if I can dream, I would like it to do port sharing and some smart branching of lines so I don't have lots of lines going from x to the bottom

imagen

If I have time and I want to play with the parameters, I can hardcode values in d2/d2layouts/d2elklayout/layout.go right?