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

Porting graphviz diagrams to diagrams #725

Open
abhisina opened this issue Jul 6, 2022 · 1 comment
Open

Porting graphviz diagrams to diagrams #725

abhisina opened this issue Jul 6, 2022 · 1 comment

Comments

@abhisina
Copy link

abhisina commented Jul 6, 2022

I have old graphviz diagrams that I am porting to diagrams for better maintenance of them but am not able to match the look and feel of it. Any help is greatly appreciated.

sample.gv

digraph G {
	bgcolor=lightpink;
	label="Sample diagram graphviz";
	labelloc=t;
	node [shape=polygon,sides=4,fillcolor=lightblue2,style="rounded,filled",fontname="Helvetica,Arial,sans-serif",color=lightblue];
	
	a -> b -> c;
	b -> d;
	a -> e [dir=both];
	a -> f;
	
	a [label="basket1\n&\nbasket2",fillcolor=yellow];
	b [label="gasket"];
	c [label="athletics association"];
	d [label="<f0> Sour Cream\n(Juice)|<f1> Fruit\n&\nPunch",shape=record,style=filled];
	e [label="<f0> Sour Dough\n(Orange)|<f1> Flight risk",shape=record,style=filled];
	f [label="Soya"];
}

Image exported with dot
sample

sample.py

#!/usr/bin/env python3

from diagrams import Diagram, Node, Edge

graph_attr = {
    "label": "Sample diagram diagrams",
    "labelloc": "t",
    "bgcolor": "lightpink",
}

node_attr = {
    "shape": "polygon",
    "sides": "4",
    "fillcolor": "lightblue2",
    "style": "rounded,filled",
    "fontname": "Helvetica,Arial,sans-serif",
    "color": "lightblue",
}

with Diagram("", show=False, direction="TB", graph_attr=graph_attr, node_attr=node_attr):
    a = Node(label="basket1\n&\nbasket2",fillcolor="yellow")
    b = Node(label="gasket")
    c = Node(label="athletics association")
    d = Node(label="<f0> Sour Cream\n(Juice)|<f1> Fruit\n&\nPunch",shape="record",style="filled")
    e = Node(label="<f0> Sour Dough\n(Orange)|<f1> Flight risk",shape="record",style="filled")
    f = Node(label="Soya")
    
    a >> b >> c;
    b >> d;
    a << Edge(minlen="0", penwidth="0.5", ltail="cluster_A", lhead="cluster_B") >> e
    a >> f;

The exported image:
diagrams_image

@clayms
Copy link

clayms commented Aug 5, 2022

change your graph_attr to the following:

graph_attr = {
    "splines":"spline",
    "label": "Sample diagram diagrams",
    "labelloc": "t",
    "bgcolor": "lightpink",
}

For record shapes see:
#290 (comment)

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

2 participants