1

这是PlantUML 中的MCVE

@startuml

'Define the components
[Main component] as c_main_component
[comp1] as c_comp1
[com2] as c_comp2
[comp3] as c_comp3
[comp4] as c_comp4

'Define the relationships
c_main_component -- c_comp3
c_main_component -- c_comp4

c_main_component - c_comp2
c_main_component - c_comp1

@enduml

以上结果如下图:

在此处输入图像描述

正如人们所看到的,comp3comp4一条漂亮的对角线Main component从底部连接它,就像预期的那样。我想要comp1并且comp2有同样漂亮的对角线Main component从右侧连接。我该怎么做?

PlantUML 使用以下选项生成的代码-debugsvek

digraph unix {
nodesep=0.486111;
ranksep=0.833333;
remincross=true;
searchsize=500;
sh0004->sh0006[arrowtail=none,arrowhead=none,minlen=0,color="#000011"];
sh0004->sh0005[arrowtail=none,arrowhead=none,minlen=0,color="#000015"];
sh0004 [shape=rect,label="",width=1.722222,height=0.522352,color="#000004"];
sh0005 [shape=rect,label="",width=0.861111,height=0.522352,color="#000005"];
sh0006 [shape=rect,label="",width=0.750000,height=0.522352,color="#000006"];
sh0007 [shape=rect,label="",width=0.861111,height=0.522352,color="#000007"];
sh0008 [shape=rect,label="",width=0.861111,height=0.522352,color="#000008"];
sh0004->sh0007[arrowtail=none,arrowhead=none,minlen=1,color="#000009"];
sh0004->sh0008[arrowtail=none,arrowhead=none,minlen=1,color="#00000D"];

}
4

2 回答 2

1

为什么要使用 forc_comp1comp2单破折号 ('-') 和 forc_comp3c_comp4双破折号 ('--')?

当使用所有双破折号时,例如:

@startuml
'Define the components
[Main component] as c_main_component
[comp1] as c_comp1
[com2] as c_comp2
[comp3] as c_comp3
[comp4] as c_comp4

'Define the relationships
c_main_component -- c_comp3
c_main_component -- c_comp4

c_main_component -- c_comp2
c_main_component -- c_comp1
@enduml

你会得到一个更好的图像:

校正后的图像

于 2018-07-15T08:24:09.593 回答
1

我做了一些摆弄,虽然我没有直接看到它在这种情况下可用,但我仍然认为它可能会给一些起点。我找到了这篇文章:How to force node position (x and y) in graphviz

基于此,我将生成的“debugsvek 文件”(cc_svek.dot)修改为(并使一些坐标有点不同,以便于头部计算并添加一些标签):

digraph unix {
nodesep=0.5;
ranksep=1;
remincross=true;
searchsize=500;
sh0004->sh0006[arrowtail=none,arrowhead=none,minlen=0,color="#000011"];
sh0004->sh0005[arrowtail=none,arrowhead=none,minlen=0,color="#000015"];
sh0004 [pos="1,-1!",shape=rect,label="4",width=1,height=0.5,color="#000004"];
sh0005 [pos="2,-0.75!",shape=rect,label="5",width=1,height=0.5,color="#000005"];
sh0006 [pos="2,-1.25!",shape=rect,label="6",width=1,height=0.5,color="#000006"];
sh0007 [pos="0,-2!",shape=rect,label="7",width=1,height=0.5,color="#000007"];
sh0008 [pos="1,-2!",shape=rect,label="8",width=1,height=0.5,color="#000008"];
sh0004->sh0007[arrowtail=none,arrowhead=none,minlen=1,color="#000009"];
sh0004->sh0008[arrowtail=none,arrowhead=none,minlen=1,color="#00000D"];

}

在其上使用命令dot -K fdp -T png cc_svek.dot时,会生成图像:

在此处输入图像描述

于 2018-07-16T11:42:31.203 回答