hbmartin / graphviz2drawio

Convert graphviz (dot) files into draw.io / lucid (mxGraph) format
http://graphviz2drawio.rtfd.io
GNU General Public License v3.0
163 stars 33 forks source link

Adds edge labels #36

Closed antback closed 5 days ago

antback commented 3 years ago

Hi,

thanks for sharing your work!

This PR allows to get the labels from the edges, as requested in #29.

Regards!

hbmartin commented 3 years ago

Thanks for the PR! I'm busy atm but will get to this in the next couple of days 😄

FabFac commented 2 years ago

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
jounathaen commented 1 year ago

I just tried it with my current .dot file and it worked! :+1:

gog182 commented 8 months ago

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="&lt;p style=&#39;margin:0px;text-align:center;margin-top:4px;;font-size:10.0px;font-family:Times New Roman,serif;color:#000000;&#39;&gt;X&lt;/p&gt;" 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="&lt;p style=&#39;margin:0px;text-align:center;margin-top:4px;;font-size:10.0px;font-family:Times New Roman,serif;color:#000000;&#39;&gt;Y&lt;/p&gt;" 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>
hbmartin commented 5 days ago

Thank you!

hbmartin commented 5 days ago

Pushed up fixes for no labels (thanks @FabFac ) and multiple labels (thanks @gog182 ) - will be shipped in the 0.3 release