diagrams icon indicating copy to clipboard operation
diagrams copied to clipboard

Is it possible to control Clusters arrangement, from left to right or top down?

Open ki11roy opened this issue 4 years ago • 6 comments

Is it possible to control Clusters arrangement, from left to right or top-down for example? How?

ki11roy avatar Feb 27 '20 10:02 ki11roy

Cluster class also has direction options, but it does not work. So I left a comment on why that does not work.

__init__.py

199: # FIXME:
200:     #  Cluster direction does not work now. Graphviz couldn't render
201:     #  correctly for a subgraph that has a different rank direction.

As the comment says, it is not supported (or impossible?) now because the Graphviz issue.

mingrammer avatar Feb 27 '20 12:02 mingrammer

i'll try to fix this

dotenorio avatar Apr 27 '20 19:04 dotenorio

failed sorry

dotenorio avatar May 06 '20 16:05 dotenorio

HI @mingrammer , awesome work with the tool.. Loving it totally. The Direction on the Clusters would have been very useful. Any idea any way this could be solved?

TheAshwanik avatar May 23 '20 18:05 TheAshwanik

As we know, Graphviz can not set a new direction (layout) in sub-rank items. Is it possible to create a sub-graph (only the Cluster) first and then put it (as image file) back to the global graph (the original Diagram)?

If we change Cluster, and render cluster to a temp svg, then we can use Custom with the temp one.

I made a demo and output like bellow: image

With this solution, we can use different layout on cluster; link cluster as node. But this solution comes with a serious drawback - edge CAN NOT link any node included in the cluster (of course).

So we must do a choice

  • link node in cluster or
  • link only the whole cluster for each cluster define.

Furthermore, more temp files generated, and the direction is a side-effect, not the major motivation

# Diagrams code demo
# Mention: I forked a version, so the code can not work in others.

with Diagram("Demo", show=False, direction="LR", filename="test", outformat='png'):

    parser = Compute('Parser & Analysis')

    with Cluster('object1',direction='LR') as cls1:
        objects = [
            Android(''),
            InternetOfThings('')
        ]

    with Cluster('object2',direction='TB') as cls2:
        objects2 = [
            Android(''),
            InternetOfThings('')
        ]

    parser - cls1
    parser >> cls1
    cls1 - cls2
    cls1 >> cls2 >> cls1

    # sorry, we can not
    # parser >> objects2

FFengIll avatar Aug 13 '20 03:08 FFengIll

This is a critical feature, without this some diagrams come out badly laid out, eg:

https://github.com/HariSekhon/Diagrams-as-Code/blob/master/opentsdb_kubernetes_hbase.py

When this should clearly be stacked on top of each other rather than this awkward side-by-side layout.

HariSekhon avatar May 02 '23 20:05 HariSekhon