graphviz2drawio
graphviz2drawio copied to clipboard
Adds edge labels
Hi,
thanks for sharing your work!
This PR allows to get the labels from the edges, as requested in #29.
Regards!
Thanks for the PR! I'm busy atm but will get to this in the next couple of days 😄
to manage case where edge does not have label
https://github.com/hbmartin/graphviz2drawio/pull/36/files#diff-63b1068513fc6bb6fa1698026dcacedf123e0f6b6f3d690f7de3ed7e5e6c0c94
def get_text(g):
if has(g, "text"):
return get_first(g, "text").text
else:
return None
I just tried it with my current .dot file and it worked! :+1:
It actually doesn't work for me, with a very simple case:
digraph {
node [shape=rectangle];
rankdir=LR;
splines=false;
"X" -> "Y"[ label="c" ];
"X" -> "Y"[ label="b" ];
"X" -> "Y"[ label="a" ];
}
Leads to only edges with "a" being extracted:
<mxGraphModel dx="289" dy="142" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="edge1" style="rounded=1;html=1;exitX=1;exitY=0.5;entryX=0;entryY=0.5;jettySize=auto;curved=0;endArrow=block;dashed=0;endFill=1;" parent="1" source="node1" target="node2" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="16d1a9ce04af4db5b41d2e3e497664ba" value="a" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="edge1" vertex="1" connectable="0">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="edge2" style="rounded=1;html=1;exitX=1;exitY=0.5;entryX=0;entryY=0.5;jettySize=auto;curved=0;endArrow=block;dashed=0;endFill=1;" parent="1" source="node1" target="node2" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ba3f85656d6745cdac7ec23bded921fc" value="a" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="edge2" vertex="1" connectable="0">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="edge3" style="rounded=1;html=1;exitX=1;exitY=0.5;entryX=0;entryY=0.5;jettySize=auto;curved=0;endArrow=block;dashed=0;endFill=1;" parent="1" source="node1" target="node2" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="5273e630be77493aa6c0da175134f37a" value="a" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="edge3" vertex="1" connectable="0">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="node1" value="<p style='margin:0px;text-align:center;margin-top:4px;;font-size:10.0px;font-family:Times New Roman,serif;color:#000000;'>X</p>" style="ellipse;verticalAlign=top;align=left;overflow=fill;html=1;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeColor=black;strokeWidth=1;fillColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="4" y="17" width="54" height="36" as="geometry" />
</mxCell>
<mxCell id="node2" value="<p style='margin:0px;text-align:center;margin-top:4px;;font-size:10.0px;font-family:Times New Roman,serif;color:#000000;'>Y</p>" style="ellipse;verticalAlign=top;align=left;overflow=fill;html=1;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeColor=black;strokeWidth=1;fillColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="101" y="17" width="54" height="36" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
Thank you!
Pushed up fixes for no labels (thanks @FabFac ) and multiple labels (thanks @gog182 ) - will be shipped in the 0.3 release