【问题标题】:graphviz: record node with a bold titlegraphviz:带有粗体标题的记录节点
【发布时间】:2011-05-30 00:28:17
【问题描述】:

我正在尝试使用 graphviz 来做一些类似于 UML 类图的事情。

我想知道是否有办法让“注册”样式的节点的第一个字段以粗体显示,以使其与其他字段不同。

我的节点如下所示:

digraph i { 
  "node" [
    label = "<f0> title | <f1> index | ... | <f2> field1 | <f3> field2"
    shape = "record"
  ];  
}

我试过了,但它不起作用:(嵌入 html)

digraph i { 
  "node" [
    label = "<f0> <B>title</B> | <f1> index | ... | <f2> field1 | <f3> field2"
    shape = "record"
  ];  
}

【问题讨论】:

    标签: uml record graphviz dot


    【解决方案1】:

    我不相信基于记录的节点允许在其中使用 HTML 格式。 node shape documentation 表明基于记录的节点已被弃用,取而代之的是使用带有HTML-like label 的非形状节点,这在格式化方面更加灵活。这些标签用 而不是双引号括起来。

    我无法对此进行测试,但这与您想要的很接近:

    digraph i { 
      "node" [
        label =<<TABLE BORDER="1" CELLBORDER="1" CELLSPACING="0">
                        <TR><TD PORT="f0"><B>title</B></TD></TR>
                        <TR><TD PORT="f1">index</TD></TR>
                        <TR><TD PORT="f2">field1</TD></TR>
                        <TR><TD PORT="f3">field2</TD></TR>
                    </TABLE>>
        shape = "none"
      ];  
    }
    

    输出:

    【讨论】:

    • 这会导致我的图片只显示单词“节点”。只有在删除 &lt;B&gt;&lt;/B&gt; 后才会显示一个表格。
    • @AndreKR 你的 Graphviz 版本可能还不支持&lt;B&gt;。见the notes in the manualNOTE:The font markups for bold, italic, underlining, subscript and superscript (&lt;B&gt;, &lt;I&gt;, &lt;U&gt;, &lt;SUB&gt; and &lt;SUP&gt;) are only available in versions after 14 October 2011, and the markup for strike-through (&lt;S&gt;) requires versions later than 15 September 2013.
    • 我也推荐BORDER="1",否则外边框会变粗。
    猜你喜欢
    • 1970-01-01
    • 2016-12-12
    • 2015-07-23
    • 1970-01-01
    • 2019-12-23
    • 2018-07-24
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    相关资源
    最近更新 更多