mingrammer / diagrams

:art: Diagram as Code for prototyping cloud system architectures
https://diagrams.mingrammer.com
MIT License
39.57k stars 2.54k forks source link

svg output is broken #1030

Open tombohub opened 1 month ago

tombohub commented 1 month ago

windows 10 graphviz 11.0.0 diagrams 0.23.4 python 3.12.2

code:

from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import RDS
from diagrams.aws.network import Route53

with Diagram("Simple Web Service with DB Cluster", show=False, outformat='svg'):
    dns = Route53("dns")
    web = ECS("service")

    with Cluster("DB Cluster"):
        db_primary = RDS("primary")
        db_primary - [RDS("replica1"),
                     RDS("replica2")]

    dns >> web >> db_primary

produces svg looking like this:

image

filipeaaoliveira commented 1 month ago

Hi @tombohub

I just tested this code locally and everything worked. Does PNG output work on this diagram and you only have problems with svg, or is that having issues as well?

tombohub commented 1 month ago

@filipeaaoliveira png works normal:

image

What could it be? Where should I look?

filipeaaoliveira commented 1 month ago

I cannot test this as I have no Windows machine, but can you test a different Graphviz version @tombohub ?

melanopsis commented 1 month ago

I see the same behavior on Linux.

diagrams: 0.23.4 graphviz: 12.1.2 simple_web_service_with_db_cluster

sieldev commented 2 weeks ago

Where are you reading the svg file ? Is it on same system where you generated or another machine ?

Because svg file embeds local system path where the diagram has been generated as you can see in attribute xlink:href:

<image xlink:href="C:\Users\xxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\resources/aws/network\elastic-load-balancing.png" width="100.8px" height="100.8px" preserveAspectRatio="xMinYMin meet" x="-2.84217e-14" y="-146.3"/>

In case you try to host your svg in a website or any other machine it will fail. So, you will have followings choices: