[Layout question] How to reduce component (or shape) due to the long label?

0 votes
asked Sep 17, 2020 in Question / help by The-Lu (63,920 points)

Hello all,

During a today's test on a diagram, I observe:

@startuml
left to right direction

cloud "Cloud" as C #pink {
cloud "c1" as c1
cloud "c2" as c2
cloud "c3" as c3
cloud "c4" as c4
}

frame "ff" as ff  {
frame "f" as f  {
[f1]
[f2]
[f3]
}
}

node "NN" as N {
node "NN" as N1
node "NN" as N2
}

f2 --> C :  2-C
C --> f3 :  C-3
f2 --> f3 : 2-3

f3 --> N  : <b><color:red>LongLongLongLongLongLongLongLongLongLongText-f3->Node
f2 --> N  : 2-N
@enduml


[See and test on PlantUML online server]

  • How to reduce the cloud?
    In order to have a concise cloud, and not a large cloud, especially due to the long red label!
  • What is the parameter to achieve this?

I test 'no-rank', without success. Perhaps another idea?

Thanks,

Regards,
Th.

commented Oct 16, 2020 by The-Lu (63,920 points)

Hello all,

After a few tests, I can change:

f2 --> C :  2-C

to

C <- f2 :  2-C

Then, we observe (the expected result):


[See on PlantUML server]

But if I increase the number of sub-cloud, the first cloud increases abnormally due to the long label...


[See on PlantUML server]


Thanks for your support,

Regards,
Th.
 

1 Answer

0 votes
answered Jan 13, 2021 by kirchsth (4,880 points)

Hi Th.,

could it be a solution that you add line breaks to the label and update the format with a helper function like below?

@startuml
left to right direction

!unquoted function $formatBreakLine($type)
!$multiLine = ""
!if (%strpos($type, "\n") >= 0)
  !while (%strpos($type, "\n") >= 0)
    !$brPos = %strpos($type, "\n")
    !$multiLine = $multiLine + %substr($type, 0, $brPos) + '</color></b>\n<b><color:red>'
    !$type = %substr($type, $brPos+2)
  !endwhile
!endif
!if (%strlen($type)>0)
  !$multiLine = $multiLine + $type
!endif
!return $multiLine
!endfunction

cloud "Cloud" as C #pink {
cloud "c1" as c1
cloud "c2" as c2
cloud "c3" as c3
cloud "c4" as c4
}

frame "ff" as ff  {
frame "f" as f  {
[f1]
[f2]
[f3]
}
}

node "NN" as N {
node "NN" as N1
node "NN" as N2
}

f2 --> C :  2-C
C --> f3 :  C-3
f2 --> f3 : 2-3

f3 --> N  : <b><color:red>$formatBreakLine(LongLong\nLongLong\nLongLongL\nongLongLo\nngLongText-f3->Node)
f2 --> N  : 2-N
@enduml

 

Best regards,
Helmut
...