diagrams
diagrams copied to clipboard
cluster width, and position
this is how my diagram looks. how can i set width, height and position of clusters?
@mingrammer need your help here.
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.
Hello @abhi0977 I'm experiencing a similar behavior. Had you managed to order or position the the nodes ?
Thanks.
Hello @abhi0977 I'm experiencing a similar behavior. Had you managed to order or position the the nodes ?
Thanks.
Nope
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 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 correct, even i've tried many things with size, ratio and width from graphviz documentation. but it did't work.
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 Edge
s 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.
@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.
I use the "invisible edge" method. See this answer for an example.
I moved to d2 lang and life is better now https://text-to-diagram.com/?example=icons
@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...