嗨,我想要一个带点语言的 uml 序列图,现在我有以下问题底部。我怎样才能做到这一点?
a b c d
| | | |
| | | |
也许我可以实现 a、b、c 和 d 及其所属边缘是集群,我为集群设置了不同的 rankdir?
编辑 刚刚通过在 a、b、c 和 d 之间添加不可见边找到了一个解决方案,但还有其他解决方案吗?
最佳答案
有志者,事竟成!
这是一个关于如何使用 dot 执行此操作的示例:
digraph SEQ_DIAGRAM {
graph [overlap=true, splines=line, nodesep=1.0, ordering=out];
edge [arrowhead=none];
node [shape=none, width=0, height=0, label=""];
{
rank=same;
node[shape=rectangle, height=0.7, width=2];
api_a[label="API A"];
api_b[label="API B"];
api_c[label="API C"];
}
// Draw vertical lines
{
edge [style=dashed, weight=6];
api_a -> a1 -> a2 -> a3;
a3 -> a4 [penwidth=5, style=solid];
a4 -> a5;
}
{
edge [style=dashed, weight=6];
api_b -> b1 -> b2 -> b3 -> b4;
b4 -> b5 [penwidth=5; style=solid];
}
{
edge [style=dashed, weight=6];
api_c -> c1;
c1-> c2 [penwidth=5, style=solid];
c2 -> c3 -> c4 -> c5;
}
// Draws activations
{ rank=same; a1 -> b1 [label="activate()"]; b1 -> c1 [arrowhead=normal]; }
{ rank=same; a2 -> b2 [style=invis]; b2 -> c2 [label="refund()", arrowhead=normal, dir=back]; }
{ rank=same; a3 -> b3 [arrowhead=normal, dir=back, label="place_order()"]; b3 -> c3; }
{ rank=same; a4 -> b4 [label="distribute()", arrowhead=normal]; }
{ rank=same; a5 -> b5 [style=invis]; b5 -> c5 [label="bill_order()", arrowhead=normal]; }
}
渲染后,这将产生以下图像:
关于这是如何实现的,有一些重要的提示:
关于uml - Graphviz 从上到下和从左到右,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1491322/