diagrams icon indicating copy to clipboard operation
diagrams copied to clipboard

cluster width, and position

Open abhi0977 opened this issue 4 years ago • 12 comments

Screenshot 2020-09-12 at 3 23 27 PM

this is how my diagram looks. how can i set width, height and position of clusters?

abhi0977 avatar Sep 12 '20 09:09 abhi0977

@mingrammer need your help here.

abhi0977 avatar Sep 21 '20 12:09 abhi0977

Its a problem I have too. I havent really got the time to look into it yet, tho.

My plan is to let diagrams generate a dot file as per https://github.com/mingrammer/diagrams/pull/182 and see if I can mess with graphviz directly. Next step would be to incorporate that into the diagrams code directly.

steschuser avatar Sep 25 '20 07:09 steschuser

Hello @abhi0977 I'm experiencing a similar behavior. Had you managed to order or position the the nodes ?

Thanks.

sitereliabilityengineer avatar Oct 02 '20 15:10 sitereliabilityengineer

Hello @abhi0977 I'm experiencing a similar behavior. Had you managed to order or position the the nodes ?

Thanks.

Nope

abhi0977 avatar Oct 02 '20 16:10 abhi0977

You didn't ask for it specifically but would you say the "problem" with your diagram is total width and lack of it autowrapping going on? Direct anwser though, positioning in relation to other graph objects is done using the rank graphiz attribute, but there are also size, pos, width, and several other attributes that would let you set what you are asking to set manually. I'd say most people are more often concerned about keeping the aspect ratio "readable" vs really trying to set sizes and positions by hand.

The ratio and size attributes passed in as graph_attrs to Diagram() is probably what you want, if not you can you be a little bit more clear about the flow positioning goal along with the code that generated that image?

redNixon avatar Oct 03 '20 13:10 redNixon

@redNixon I've tried changing ratio, size, ratio with different settings, and it didn't change nothing at all. Only to remember you, that I have approx 50 nodes of the same cluster, all in the same column, and I will prefer to be aligned in different columns.

Is not great having all the nodes in one column or at least to be presented in a webpage or report.

I will continue testing, but to be honest, I have no experience with graphviz at all.

Thanks!

sitereliabilityengineer avatar Oct 06 '20 18:10 sitereliabilityengineer

@sitereliabilityengineer correct, even i've tried many things with size, ratio and width from graphviz documentation. but it did't work.

abhi0977 avatar Oct 10 '20 04:10 abhi0977

I have had some success using a transparent png (a non-existent png also works - if you don't mind the Warnings) in a Custom node, together with an Edge with the penwidth set to "0.0", i.e. Edge(penwidth="0.0").

I use the transparent Custom nodes as spacers to shift around the Clusters and use the transparent Edges to tie things down to a visible Node.

It is a pain though and you have to fuss around with it to get it how you want, and it is still rarely exactly what you want.

clayms avatar Oct 27 '20 02:10 clayms

@abhi0977 have a look at this answer: https://github.com/mingrammer/diagrams/issues/243#issuecomment-721971788

if you change the "layout" engine to either "neato" or "fdp", and then for each Node set the pin to "true" and set the pos (position) to the "x,y" you want.

clayms avatar Nov 04 '20 21:11 clayms

I use the "invisible edge" method. See this answer for an example.

OzNetNerd avatar Dec 04 '20 04:12 OzNetNerd

I moved to d2 lang and life is better now https://text-to-diagram.com/?example=icons

pablodz avatar Feb 04 '23 08:02 pablodz

@pablodz I've also moved to D2 lang when I couldn't get cluster position placement as demonstrated in my diagram in https://github.com/mingrammer/diagrams/issues/891, although since then that ticket has some good ideas thanks to @clayms.

D2 is awesome too... but it also has a limitation in that it can specify a position placement field called near but you can't connect positioned and unpositioned objects while using that, see https://github.com/terrastruct/d2/issues/1285 so there's no free lunch... might have to mix and match engines for different use cases until this field matures more...

HariSekhon avatar May 05 '23 05:05 HariSekhon