graphviz点流程图表格标签放置,有时会被截断

graphviz点流程图表格标签放置,有时会被截断,graphviz,dot,Graphviz,Dot,我已经创建了一个相当大的流程图。某些边标签(呈现为表格)存在以下问题: 某些表格单元格中的文本在表格单元格外结束 这张桌子有时会穿过边缘 当流程图呈现为PNG图像(这是我想要的输出)时, 然后,这些表的某些部分位于图像区域之外 该图的思想是有一个水平的时间轴,同时有“列节点”(或在时间轴中紧密相连)。因此,为了加强这个“时间流”,我最终使用了rankdir=“LR”以及{rank=same;我的第一个节点;我的第二个节点;} 如何使这些“表格标签”的渲染效果更好一些?比如不交叉边缘,将文本完

我已经创建了一个相当大的流程图。某些边标签(呈现为表格)存在以下问题:

  • 某些表格单元格中的文本在表格单元格外结束
  • 这张桌子有时会穿过边缘
  • 当流程图呈现为PNG图像(这是我想要的输出)时, 然后,这些表的某些部分位于图像区域之外
该图的思想是有一个水平的时间轴,同时有“列节点”(或在时间轴中紧密相连)。因此,为了加强这个“时间流”,我最终使用了
rankdir=“LR”
以及
{rank=same;我的第一个节点;我的第二个节点;}

如何使这些“表格标签”的渲染效果更好一些?比如不交叉边缘,将文本完全放在表格单元格内,在导出到PNG时看到完整的图形?

我使用以下命令生成PNG输出图像:
dot-Tpng foo.dot-o foo.PNG
,请参见下面的“表格标签”问题:

有向图my_流{
//全局图形态
rankdir=“LR”//orziontal
nodesep=0.9;
//共享配置
边缘[fontname=“Courier New”,fontsize=20];
节点[fontname=Helvetica,fontsize=26,style=“圆角,填充”,nojustify=true];
//许多不同的节点“类”
节点[形状=双圆,颜色=纳瓦霍维特]
我的第一个节点;我的第二个节点;
节点[shape=rect,color=aquamarine2]
第一个标准水平节点;第二个标准水平节点;
//每个节点的自定义配置
第一个水平节点[label=“第一个水平节点”]
第二个水平节点[label=“第二个水平节点”]
my\u first\u节点[label=“my\l first\l节点”]
我的第二个节点[label=“我的第二个节点”]
//同一“列”中的节点集
{rank=same;我的第一个节点;我的第二个节点;}
第一个标准水平节点->第二个标准水平节点
第二个标准水平节点->我的第一个节点
我的第一个节点->我的第二个节点[标签=];
}

如果将表放在节点而不是边缘标签中,情况会更好;使用HTML标记

,您可以在表中换行。根据需要编辑代码,我提出了

digraph my_flow {
  // global graph conf
  rankdir="LR"; // horizontal
  nodesep=0.9;

  // shared conf
  node [ fontname=Helvetica, fontsize=26, style="rounded,filled", nojustify=true];

  // node instead of edge label
  my_table[ shape=none, margin=0, fontname="Courier New", fontsize=20, label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
           <TR><TD BGCOLOR="gray">action type 1</TD></TR>
           <TR><TD BGCOLOR="white">action 1<BR/>very very very very<BR/>long description</TD></TR>
           <TR><TD BGCOLOR="gray">action type 2</TD></TR>
           <TR><TD BGCOLOR="white">action X</TD></TR>
           <TR><TD BGCOLOR="white">action Y</TD></TR>
           <TR><TD BGCOLOR="gray">action type 3</TD></TR>
           <TR><TD BGCOLOR="white">action A</TD></TR>
           <TR><TD BGCOLOR="white">action B</TD></TR>
           <TR><TD BGCOLOR="white">action C</TD></TR>
           <TR><TD BGCOLOR="gray">action type 4</TD></TR>
           <TR><TD BGCOLOR="white">action Q</TD></TR>
           <TR><TD BGCOLOR="white">action W</TD></TR>
         </TABLE>> ]

  // many different node "classes"
  node[shape=doublecircle, color=navajowhite]
    my_first_node; my_second_node;
  node[shape=rect, color=aquamarine2]
    first_std_horiz_node; second_std_horiz_node;

  // custom configuration for each node
  first_std_horiz_node[label="First \l std \l horizontal \l node"]
  second_std_horiz_node[label="Second \l std \l horizontal \l node"]
  my_first_node[label="My \l first \l node"]
  my_second_node[label="My \l second \l node"]

  // sets of nodes in the same "column"
  {rank=same; my_first_node; my_table; my_second_node; }

  first_std_horiz_node -> second_std_horiz_node -> my_first_node;
  my_first_node -> my_table[ dir = none ];
  my_table -> my_second_node;
}
有向图my_流{
//全局图形态
rankdir=“LR”//水平
nodesep=0.9;
//共享配置
节点[fontname=Helvetica,fontsize=26,style=“圆角,填充”,nojustify=true];
//节点而不是边标签
我的表格[形状=无,边距=0,fontname=“Courier New”,fontsize=20,标签=<
动作类型1
动作1
非常长的描述 行动类型2 行动十 行动Y 动作类型3 行动A 行动B 行动C 动作类型4 行动Q 行动W > ] //许多不同的节点“类” 节点[形状=双圆,颜色=纳瓦霍维特] 我的第一个节点;我的第二个节点; 节点[shape=rect,color=aquamarine2] 第一个标准水平节点;第二个标准水平节点; //每个节点的自定义配置 第一个水平节点[label=“第一个水平节点”] 第二个水平节点[label=“第二个水平节点”] my\u first\u节点[label=“my\l first\l节点”] 我的第二个节点[label=“我的第二个节点”] //同一“列”中的节点集 {rank=same;我的第一个节点;我的表;我的第二个节点;} 第一个标准水平节点->第二个标准水平节点->我的第一个节点; my_first_节点->my_表[dir=none]; 我的表格->我的第二个节点; }
产生

编辑

在修改表格代码后,也可以将表格用作标签;为便于参考,请再次阅读完整代码:

digraph my_flow {
  // global graph conf
  rankdir="LR"; // horizontal
  nodesep=0.9;

  // shared conf
  node [ fontname=Helvetica, fontsize=26, style="rounded,filled", nojustify=true];

  // node instead of edge label


  // many different node "classes"
  node[shape=doublecircle, color=navajowhite]
    my_first_node; my_second_node;
  node[shape=rect, color=aquamarine2]
    first_std_horiz_node; second_std_horiz_node;

  // custom configuration for each node
  first_std_horiz_node[label="First \l std \l horizontal \l node"]
  second_std_horiz_node[label="Second \l std \l horizontal \l node"]
  my_first_node[label="My \l first \l node"]
  my_second_node[label="My \l second \l node"]

  // sets of nodes in the same "column"
  {rank=same; my_first_node; my_second_node; }

  first_std_horiz_node -> second_std_horiz_node -> my_first_node;
  my_first_node -> my_second_node[ fontname="Courier New", fontsize=20, label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
           <TR><TD BGCOLOR="gray">action type 1</TD></TR>
           <TR><TD BGCOLOR="white">action 1<BR/>very very very very<BR/>long description</TD></TR>
           <TR><TD BGCOLOR="gray">action type 2</TD></TR>
           <TR><TD BGCOLOR="white">action X</TD></TR>
           <TR><TD BGCOLOR="white">action Y</TD></TR>
           <TR><TD BGCOLOR="gray">action type 3</TD></TR>
           <TR><TD BGCOLOR="white">action A</TD></TR>
           <TR><TD BGCOLOR="white">action B</TD></TR>
           <TR><TD BGCOLOR="white">action C</TD></TR>
           <TR><TD BGCOLOR="gray">action type 4</TD></TR>
           <TR><TD BGCOLOR="white">action Q</TD></TR>
           <TR><TD BGCOLOR="white">action W</TD></TR>
         </TABLE>> ];
}
有向图my_流{
//全局图形态
rankdir=“LR”//水平
nodesep=0.9;
//共享配置
节点[fontname=Helvetica,fontsize=26,style=“圆角,填充”,nojustify=true];
//节点而不是边标签
//许多不同的节点“类”
节点[形状=双圆,颜色=纳瓦霍维特]
我的第一个节点;我的第二个节点;
节点[shape=rect,color=aquamarine2]
第一个标准水平节点;第二个标准水平节点;
//每个节点的自定义配置
第一个水平节点[label=“第一个水平节点”]
第二个水平节点[label=“第二个水平节点”]
my\u first\u节点[label=“my\l first\l节点”]
我的第二个节点[label=“我的第二个节点”]
//同一“列”中的节点集
{rank=same;我的第一个节点;我的第二个节点;}
第一个标准水平节点->第二个标准水平节点->我的第一个节点;
my_first_node->my_second_node[fontname=“Courier New”,fontsize=20,标签=<
动作类型1
动作1
非常长的描述 行动类型2 行动十 行动Y 动作类型3 行动A 行动B 行动C 动作类型4 行动Q 行动W > ]; }
产生


在给定的上下文中,我发现节点解决方案更可取/更干净,因为它使表中的信息所属的位置更清晰。但是,如果还有更多,边缘方法也会起作用。

很遗憾,
不受Graphviz的支持。@vaettchen I希望使用边缘和节点将“动作”与“状态/实体”分开。大多数情况下,这些表格都很小,而且很适合靠近边缘(带有曲线)。通过这种方式,我认为在查看图形时,很清楚这些表的用途,因为它们不会与节点混合。无论如何,是的,这个节点技巧似乎避免了大多数关于呈现一个大表的问题。谢谢@TPPZ,请参见我的编辑-如果控制表格的宽度,边缘也可以工作。
digraph my_flow {
  // global graph conf
  rankdir="LR"; // horizontal
  nodesep=0.9;

  // shared conf
  node [ fontname=Helvetica, fontsize=26, style="rounded,filled", nojustify=true];

  // node instead of edge label


  // many different node "classes"
  node[shape=doublecircle, color=navajowhite]
    my_first_node; my_second_node;
  node[shape=rect, color=aquamarine2]
    first_std_horiz_node; second_std_horiz_node;

  // custom configuration for each node
  first_std_horiz_node[label="First \l std \l horizontal \l node"]
  second_std_horiz_node[label="Second \l std \l horizontal \l node"]
  my_first_node[label="My \l first \l node"]
  my_second_node[label="My \l second \l node"]

  // sets of nodes in the same "column"
  {rank=same; my_first_node; my_second_node; }

  first_std_horiz_node -> second_std_horiz_node -> my_first_node;
  my_first_node -> my_second_node[ fontname="Courier New", fontsize=20, label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
           <TR><TD BGCOLOR="gray">action type 1</TD></TR>
           <TR><TD BGCOLOR="white">action 1<BR/>very very very very<BR/>long description</TD></TR>
           <TR><TD BGCOLOR="gray">action type 2</TD></TR>
           <TR><TD BGCOLOR="white">action X</TD></TR>
           <TR><TD BGCOLOR="white">action Y</TD></TR>
           <TR><TD BGCOLOR="gray">action type 3</TD></TR>
           <TR><TD BGCOLOR="white">action A</TD></TR>
           <TR><TD BGCOLOR="white">action B</TD></TR>
           <TR><TD BGCOLOR="white">action C</TD></TR>
           <TR><TD BGCOLOR="gray">action type 4</TD></TR>
           <TR><TD BGCOLOR="white">action Q</TD></TR>
           <TR><TD BGCOLOR="white">action W</TD></TR>
         </TABLE>> ];
}