PlantUml: How to do a multiline display in opt condition for sequence diagram
Asked Answered
M

1

10

Im trying to do a UML diagram for a script below in PlantUML.

[plantuml, target=diagram-sequence, format=png] 
....
@startuml
-> A: test
opt ((Exterme_DANGER_Forwith_cIES_MICRO_GYRO) || (Exterme_DANGER_Forwith_cIES_PANASONIC_GYRO)  || (Exterme_DANGER_Forwith_cIES_VIRTUAL)    || (Exterme_DANGER_Forwith_cIES_Cobra)     || (Exterme_DANGER_Forwith_cIES_VTI)    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)    || (Exterme_DANGER_Forwith_cIES_VTI)     || (Exterme_DANGER_Forwith_cIES_VTI_SPI)   || (Exterme_DANGER_Forwith_cIES_VIRTUAL))    || (Exterme_DANGER_Forwith_cIES_Cobra5)  || (Exterme_DANGER_Forwith_cIES_Cobra4))
<- A
end opt
@enduml
....

When I do this I cannot see the complete diagram. PlantUML DIAGRAM

Does anyone know of a way to show the big opt conditon in multiple lines in the diagram?

Meryl answered 23/2, 2022 at 9:36 Comment(2)
Maybe you should try a few \n in the code like ` @startuml ... opt ((Exterme_DANGER_Forwith_cIES_MICRO_GYRO) || (Exterme_DANGER_Forwith_cIES_PANASONIC_GYRO) || \n (Exterme_DANGER_Forwith_cIES_VIRTUAL) || (Exterme_DANGER_Forwith_cIES_Cobra) || \n ... end opt @endumlStage
ah ok , if I use \n but keep it in the same line while scripting. It works. Thanks a lot!Meryl
M
12

Adding newlines \n will break the opt across multiple lines in the diagram, but it will still be on one in the PlantUML text file, which can be hard to read.

To make things more readable, adding \ at the end of the line will allow splitting text across multiple lines.

Combining \n with \ allow splitting the single line across multiple lines in both the diagram and the file:

@startuml
-> A: test
opt ( \
    (Exterme_DANGER_Forwith_cIES_MICRO_GYRO)       \n\
    || (Exterme_DANGER_Forwith_cIES_PANASONIC_GYRO)\n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)       \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra)         \n\
    || (Exterme_DANGER_Forwith_cIES_VTI)           \n\
    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)       \n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)       \n\
    || (Exterme_DANGER_Forwith_cIES_VTI)           \n\
    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)       \n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL))      \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra5)        \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra4)        \n\
)
<- A
end opt
@enduml

Marcum answered 5/3, 2022 at 13:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.