Friday 5 May 2023

is there a way to force a cluster to go on top of the diagram in diagrams

I'm using diagrams and I'm trying to force a cluster to go on top.

Aplogies for the long code example, I didn't manage to render anything with less complexity that conveyed the same issue.

import os
from diagrams import Cluster, Diagram, Edge
from diagrams.onprem.client import User

with Diagram("test", show=False) as diag:
    a = User("a")
    b = User("b")
    c = User("c")

    with Cluster("THIS CLUSTER SHOULD BE ON TOP"):
        d1 = User("d1")
        d2 = User("d2")
        d3 = User("d3")
        d1 - Edge(style="invis") - d2

    with Cluster("E"):
        e1 = User("e1")
        e2 = User("e2")
        e1 >> e2
        e_anchor = User("")
        e_anchor >> d1

    f = User("f")

    with Cluster("G"):
        with Cluster("H"):
            g1 = User("g1")
            g2 = User("g2")
            g3 = User("g3")
            g_anchor = User("")
            g_anchor >> d2
        g4 = User("g4")
        g5 = User("g5")
        g1 >> g2
        g2 >> g3
        g3 >> g5
        g4 >> g5

    g6 = User("g6")

    with Cluster("I"):
        i1 = User("i1")
        i2 = User("i2")
        i3 = User("i3")
        Cs = [i1, i2, i3]

    with Cluster("J"):
        j1 = User("j1")

    k = User("k")

    c << d3
    k >> d3

    a >> b
    b >> c
    c >> e1
    e2 >> f
    f >> g1
    f >> g4
    g5 >> g6
    g6 >> Cs

    for ccc in Cs:
        ccc >> j1

    j1 >> k

Which renders: enter image description here

Note how if the highlighted cluster was forced to go on the top/bottom of the diagram, the edges to/from it would pollute it much less

enter image description here

Any ideas? ChatGPT4 hallucinates this to no end...



from is there a way to force a cluster to go on top of the diagram in diagrams

No comments:

Post a Comment