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

re-arrange the diagram componentes #522

Open
hbriqi opened this issue Apr 28, 2021 · 5 comments
Open

re-arrange the diagram componentes #522

hbriqi opened this issue Apr 28, 2021 · 5 comments

Comments

@hbriqi
Copy link

hbriqi commented Apr 28, 2021

how i can programmatically arrange the location of components (e.g. nodes and cluster) to be sorted in a specific way?

@gabriel-tessier
Copy link
Collaborator

Hi @hisham-elbreky

Can you provide more details about what you want to do?

If you talk about order for display you can check the "direction" parameter.
From the example in the doc: https://diagrams.mingrammer.com/docs/getting-started/examples

The first example with direction parameter set to TB for Top to Bottom.
with Diagram("Grouped Workers", show=False, direction="TB"):

@hbriqi
Copy link
Author

hbriqi commented Apr 29, 2021

Thanks @gabriel-tessier

that is really helpful to use direction, but seems it not works well with cluster

I am trying to generate physical diagram with many clusters. The diagram depict zones, tiers, and then nodes and its connections, and I am trying to make each cluster/component in the right position

@gabriel-tessier
Copy link
Collaborator

For your case you may check about the edge length to push the clsuters and make space between, check the example in this comment which are very good:
#433 (comment)

Also you can check about this issue which have a better example with direction:
#475

If you can put your code to generate your graph it may help to reproduce your problem and try to find a better solution.

@hbriqi
Copy link
Author

hbriqi commented May 23, 2021

Thanks @gabriel-tessier

I'd like to share with you my code here as a public github repo so anyone can share, participate, or take the benefit of opensource code

@mike-pt
Copy link

mike-pt commented Dec 15, 2022

So I looked at a few of this but I can't really figure how to get the item properly order, I also don't know why it re-orders differently from how they are added in code.

This is something basic I have:

with Diagram("Resilience Diagram", direction="LR") as diag:
    region = Cluster("Region: us-central", direction="TB")


    with region:
        zones = [ 'us-central1-b', 'us-central1-c']

        with Cluster('us-central1-a'):
            db = SQL("Master")
            GKE("Cluster Node") >> Edge(forward=True, reverse=True) >> db
        for _ in zones:
            with Cluster(_,graph_attr=zone_gattr):
                GKE("Cluster Node") >> Edge(forward=True, reverse=True) >> db

And this is the result (but I don't know why is us-central1-a in the middle? I want it to show as the first item):

image

I've tried several things suggested on other posts like adding positions and changing the layout but that only either breaks it all for me or doesn't affect the result, so if there is any kind soul, with this how would I make sure central1-a is the first item?

thanks

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

3 participants