Search code examples
htmlgraphviz

Space around html nodes


How can I make the links connect the border of HTML nodes ?

graph {
  node[shape=plaintext];
  Object1[label=<<table><tr><td>Object1</td></tr></table>>];
  Object2[label=<<table><tr><td>Object2</td></tr></table>>];
  Link[shape="diamond", label="Link"];
  Object1 -- Link;
  Object2 -- Link;
}

Compilation : dot -Tpng file.gv

Result : Objects borders are a bit too far from the links extremities.


Solution

  • Found an acceptable solution using references "port" inside TD cells:

    graph {
      node[shape=plaintext];
      Object1[label=<<table border="0"><tr><td border="1" port="f1">Object1</td></tr></table>>];
      Object2[label=<<table border="0"><tr><td border="1" port="f2">Object2</td></tr></table>>];
      Link[shape="diamond", label="Link"];
      Object1:f1 -- Link;
      Object2:f2 -- Link;
    }
    

    (inspired by an example near the end of the doc page https://www.graphviz.org/doc/info/shapes.html)

    Result