Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make edges between grid cells orthogonal #84

Open
meanderix opened this issue Aug 27, 2024 · 10 comments
Open

Make edges between grid cells orthogonal #84

meanderix opened this issue Aug 27, 2024 · 10 comments

Comments

@meanderix
Copy link

meanderix commented Aug 27, 2024

image

grid-rows: 3
grid-columns: 3
grid-gap: 20
1
2
3
4
5
6
7
8
9
1 -> 3 -> 9 -> 7 -> 1
1 -> 9
3 -> 7

Looks like the edges internal to a grid structure do not respect orthogonality rules.

@meanderix meanderix changed the title Make edges within grid cells orthogonal Make edges between grid cells orthogonal Aug 28, 2024
@alixander
Copy link
Contributor

alixander commented Aug 28, 2024

@meanderix can you draw your ideal pathing? I think going around the outside will look weird too. I think internal grid edges is a case where most of the time you want just the straight line. If you have many internal grid edges, it quickly ends up like a maze of overlapping routes otherwise.

@meanderix
Copy link
Author

@alixander
image
Here's another example where I want to achieve a specific grid layout (4x2). Here it would have been super useful with orthogonal edges. Perhaps this could be set optionally through a directive?

(The previous example was a bit hypothetical and I understand that there are also use cases for non-orthogonal edges.)

@alixander
Copy link
Contributor

@meanderix Thank you for the example. I suppose grid was cleaner than if you had run this without grid?

Because I feel like the grid is just a suboptimal placement for this use case. This is the best route I can come up with and it doesn't look great.

Screenshot 2024-08-29 at 11 13 00 AM

I suppose you could increase the gap size so that the routes go in between, but there's still no way to avoid overlap.

@meanderix
Copy link
Author

@alixander
image
Here's what you get without the grid. The grid layout is so much better for this use case. Also, coming from Mermaid and its flowcharts, I find the grid feature really one of the selling points of D2. Especially when you need to visually express some kind of ordering.

@meanderix
Copy link
Author

image
This is also interesting. If you wrap the upper and lower row in its own box, then you will have mixed results with the edges ...

@alixander
Copy link
Contributor

In this case it wasn't able to find a route for Monitor -> Plan.

You gave my last comment a thumbs up, does that mean the route I proposed is one you'd be satisfied with?

@meanderix
Copy link
Author

@alixander Well, I would be happy with orthogonal edges. I guess the optimal path depends. Maybe a "dynamic gap" between rows/columns could also be an option in order to allow a connection in between grid cells. (But I can understand that it adds complexity to the implementation.)

@alixander
Copy link
Contributor

Idk, even if there's gap, it still overlaps weirdly. I feel like the construction just doesn't allow for good pathing. I believe this is a case where user design goes further than any edge routing can compensate for. Like this seems to me like a better way to do this (direction: left on the bottom container)

Screenshot 2024-08-30 at 2 46 08 PM

@meanderix
Copy link
Author

@alixander
image
Some architect diagram tools, such as Archimate, will have these nifty bends when two edges are crossing. I don't know if that would be useful also for D2. (I'm just thinking out loud about possible ways to still support orthogonal edges...)

@alixander
Copy link
Contributor

Right, crossing bridges is a feature request: terrastruct/d2#1932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants