简体   繁体   English

Graphviz:如何在HTML表格单元格之间创建边缘?

[英]Graphviz: How can I create edges between HTML table cells?

Please consider the following code: 请考虑以下代码:

digraph G {
    node [shape=plaintext]

    a [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
                           <TR><TD ID="first" BGCOLOR="gray">first</TD></TR>
                           <TR><TD ID="second" PORT="f1">second</TD></TR>
                           <TR><TD ID="third" PORT="f2">third</TD></TR>
              </TABLE>>];

    b [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
                           <TR><TD ID="first" BGCOLOR="gray">first</TD></TR>
                           <TR><TD ID="second" PORT="f1">second</TD></TR>
                           <TR><TD ID="third" PORT="f2">third</TD></TR>
              </TABLE>>];

    a:first -> b:first;
}

I get a fair amount of warnings: 我得到了相当多的警告:

laci@nitehawk ~ $ dot records.gv -T pdf > records.pdf
Warning: Illegal attribute ID in <TD> - ignored
Warning: Illegal attribute ID in <TD> - ignored
Warning: Illegal attribute ID in <TD> - ignored
in label of node a
Warning: Illegal attribute ID in <TD> - ignored
Warning: Illegal attribute ID in <TD> - ignored
Warning: Illegal attribute ID in <TD> - ignored
in label of node b
Warning: node a, port first unrecognized
Warning: node b, port first unrecognized
  1. According to the documentation the ID attribute of TD should be legal. 根据文件 ,TD的ID属性应该是合法的。 What am I missing? 我错过了什么?
  2. How can I reference individual cells and create edges between them? 如何引用单个单元格并在它们之间创建边缘?

For completeness sake here's the full source that actually works: 为了完整起见,这里是实际工作的完整来源:

digraph G {
    node [shape=plaintext]

    a [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
                           <TR><TD PORT="c" BGCOLOR="gray">first</TD></TR>
                           <TR><TD PORT="d">second</TD></TR>
                           <TR><TD PORT="e">third</TD></TR>
              </TABLE>>];

    b [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
                           <TR><TD PORT="c" BGCOLOR="gray">first</TD></TR>
                           <TR><TD PORT="d">second</TD></TR>
                           <TR><TD PORT="e">third</TD></TR>
              </TABLE>>];

    a:c -> b:c;
}

You can simply use PORT instead of ID and then use the edge definition as in your example. 您可以简单地使用PORT而不是ID ,然后使用边缘定义,如示例中所示。

<TD PORT="first" BGCOLOR="gray">first</TD>

ID 's purpose is downstream use , so unless you're using SVG output and reuse the id's elsewhere, they are probably not really useful. ID的目的是下游使用 ,所以除非你使用SVG输出并在其他地方重用id,否则它们可能并不真正有用。

As to the warnings, I do not get them with graphviz 2.28. 关于警告,我没有使用graphviz 2.28。 If you use an older version of graphviz, I suggest to update. 如果你使用旧版本的graphviz,我建议你更新。

graphviz html标签端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM