Refael Sheinker
Refael Sheinker

Reputation: 891

2 components on the side in PlantUML

Here is MCVE in PlantUML:

@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

The above results in the below image:

enter image description here

As one can see, comp3 and comp4 have a nice a diagonal lines connecting it to Main component from the bottom, just like expected. I want comp1 and comp2 have the same nice diagonal lines to connect to Main component from the right side. How can I do it?

The code as generated by PlantUML with the option -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"];

}

Upvotes: 1

Views: 939

Answers (2)

albert
albert

Reputation: 9047

I did some fiddling around and although I don't directly see it usable in this case I still think it might give some points to start. I found this article: How to force node position (x and y) in graphviz

Based on this I modified the resulting "debugsvek file" (cc_svek.dot) to (and made some coordinates a bit different for easier calculations by head and added some labels):

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"];

}

When using the command dot -K fdp -T png cc_svek.dot on it this results in the image:

enter image description here

Upvotes: 1

albert
albert

Reputation: 9047

Why are you using for c_comp1 and comp2 a single dash ('-') and for c_comp3 and c_comp4 a double dash ('--')?

When using for all a double dash like:

@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

You will get a nicer image:

corrected image

Upvotes: 1

Related Questions