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

Difficulty Organizing Diagram Items into Multiple Rows for Improved Readability #1013

Open
MoriyaAkamai opened this issue Aug 22, 2024 · 0 comments

Comments

@MoriyaAkamai
Copy link

Hey, I’m trying to create a diagram where I have multiple items arranged in rows instead of all being in a single row. Currently, all the items are displayed in one long row, which makes it difficult to read and understand the diagram clearly. I’m aiming to split the items into multiple rows so that the layout is more organized and easier to visualize. Do you have any suggestions or solutions for achieving this?
Screenshot 2024-08-22 at 5 21 26 PM

from diagrams import Diagram, Cluster, Edge
from diagrams.azure.compute import AKS
from diagrams.k8s.ecosystem import Helm
from diagrams.onprem.network import Nginx
from diagrams.onprem.gitops import Argocd
from diagrams.custom import Custom
from diagrams.azure.network import DNSZones

# Custom class for handling custom icons
class MyCustomDiagram(Custom):
    def __init__(self, label, icon_path):
        super().__init__(label, icon_path=icon_path)

# Define common graph attributes
_default_graph_attrs = {
    "fontsize": "35",
    "nodesep": "4.0",
    "ranksep": "2.0"
}

_cluster_default_graph_attrs = {
    "bgcolor": "white",  
    "fontsize": "30"
}

_app_default_graph_attrs = {
    "fontsize": "18"
}

# Define common edge attributes
common_edge_attrs = {
    "color": "blue",
    "style": "solid",
    "label": "Helm"
}


# Define a function to create a common cluster layout
def create_applications_cluster(cluster_name, app_list):
    with Cluster(cluster_name, graph_attr=_app_default_graph_attrs):
        for app in app_list:
            if "label" in app:
                app["object"] = MyCustomDiagram(app["label"], app["icon_path"])
            else:
                app["object"] = MyCustomDiagram("", app["icon_path"])
            yield app["object"]

    # __directions = ("TB", "BT", "LR", "RL")

# Create the main diagram
with Diagram("CPC infrastructure", show=False, direction="TB", graph_attr=_default_graph_attrs):
        
    with Cluster("App cluster", graph_attr=_cluster_default_graph_attrs):
        argocd = Argocd("ArgoCD")
        rancher = MyCustomDiagram("Rancher", "/Users/mnadav/Downloads/linode/images/rancher.png")

        # Applications inside Red Panda Cluster
        apps = {
            "NGINX Ingress": {"label": "NGINX Ingress", "icon_path": "/Users/mnadav/Downloads/linode/images/nginx.png"},
            "Cert Manager": {"label": "Cert Manager", "icon_path": "/Users/mnadav/Downloads/linode/images/cert-manager.png"},
            "external-dns": {"icon_path": "/Users/mnadav/Downloads/linode/images/external-dns.png"},
            "External Secrets": {"label": "External Secrets", "icon_path": "/Users/mnadav/Downloads/linode/images/external-secrets.png"},
            "Calico": {"label": "Calico", "icon_path": "/Users/mnadav/Downloads/linode/images/calico.jpeg"},
            "Keda": {"icon_path": "/Users/mnadav/Downloads/linode/images/keda.png"},
            "Keel": {"label": "Keel", "icon_path": "/Users/mnadav/Downloads/linode/images/keel.png"},
            "Memcached": {"icon_path": "/Users/mnadav/Downloads/linode/images/memcached.png"},
            "Redis": {"icon_path": "/Users/mnadav/Downloads/linode/images/redis.png"},
            "Reloader": {"label": "Reloader", "icon_path": "/Users/mnadav/Downloads/linode/images/reloader.png"},
            "Victoria Metrics": {"label": "Victoria Metrics", "icon_path": "/Users/mnadav/Downloads/linode/images/victoria-metrics.jpeg"},
            "Linkerd": {"label": "Linkerd", "icon_path": "/Users/mnadav/Downloads/linode/images/linkerd.png"},
            "Metrics Server": {"icon_path": "/Users/mnadav/Downloads/linode/images/metrics-server.png"},
            "Wiz": {"icon_path": "/Users/mnadav/Downloads/linode/images/wiz.png"}

        }
        # Iterate over the dictionary values
        for app in create_applications_cluster("Argocd Infra Applications", apps.values()):
            argocd >> Edge(**common_edge_attrs) >> app
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

1 participant