Why are all components showing all cards in reverse order, even if I declare the reverse order?

0 votes
asked May 26, 2025 in Question / help by dylan (120 points)

I am new to PlantUML, so maybe this is a simple thing. I order my sub-components 1, 2, 3; they are displayed 3, 2, 1. Since I'm using left to right direction, I guess that this affects the display order. So I reorder 3, 2, 1 -- and the display order is ... 3, 2, 1 !

What kind of logic is this? Why on earth would PlantUML ignore the order in which something is defined?

My code:

@startuml
left to right direction
skinparam componentStyle rectangle

component "Comp1" {
  [Application UI 1]
  [Application UI 2]
}
component "Comp2" {
  [Application Service 1]
  [Application Service 2]
}
' this aligns the arrows
[Application UI 1] -[hidden]-> [Application Service 2]
[Application UI 2] -[hidden]-> [Application Service 1]

[Application UI 1] -> [Application Service 1]
[Application UI 2] -> [Application Service 2]

component "Comp3" {
   database "Database"
   [External API]
   [Message Queue]
}

[Application Service 1] --> [Database]
[Application Service 1] --> [External API]
[Application Service 1] --> [Message Queue]

component "Comp4" {
   [Thing 1]
   [Thing 2]
   [Thing 3]
}

[Application Service 1] --> [Thing 1]
[Application Service 1] --> [Thing 2]
[Application Service 2] -> [Thing 2]
[Application Service 2] -> [Thing 3]

component "Comp5" {
   [A Platform]
   [An Index]
   [Yes]
}

[Application Service 1] -> [A Platform]
[Application Service 1] -> [An Index]
[Thing 1] -right-> [An Index]
[Thing 1] -right-> [Yes]

"Comp4" -[hidden]r-> "Comp5"
"Comp3" -[hidden]-> "Comp5"

@enduml

(The result I will put in the next message - this one is apparently too long.)

All sub-components in reverse order, and Comp 3 and Comp4 in reverse order. If I re-order the sub-components, it's exactly the same result.

BTW, I interrogated Google's AI on this for an hour, it couldn't handle it. It suggested right to left direction (syntax error) and order keyword (syntax error).

If anyone has an idea, please let me know!!

commented May 26, 2025 by dylan (120 points)
Well I would love to show a screenshot of the result, but I can't: "Messages cannot be more than 8000 characters".

Anyone know how to upload an image here?

Incidentally, the hidden lines in the code are to arrange the components correctly, and they do actually work. It's fiddly but good enough. If I could get the order right, this is good to go...

1 Answer

0 votes
answered May 26, 2025 by The-Lu (87,580 points)

Hello D.,

Here is a proposal:

@startuml
left to right direction
skinparam componentStyle rectangle

component "Comp1" {
  [Application UI 1]
  [Application UI 2]
}
component "Comp2" {
  [Application Service 1]
  [Application Service 2]
}

[Application UI 1] --> [Application Service 1]
[Application UI 2] --> [Application Service 2]

component "Comp3" {
   database "Database"
   [External API]
   [Message Queue]
}

[Application Service 1] --> [Database]
[Application Service 1] --> [External API]
[Application Service 1] --> [Message Queue]

component "Comp4" {
   [Thing 1]
   [Thing 2]
   [Thing 3]
}

[Application Service 1] ---> [Thing 1]
[Application Service 1] ---> [Thing 2]
[Application Service 2] ---> [Thing 2]
[Application Service 2] ---> [Thing 3]

component "Comp5" {
   [A Platform]
   [An Index]
   [Yes]
}

[Application Service 1] ----> [A Platform]
[Application Service 1] ----> [An Index]
[Thing 1] -right-> [An Index]
[Thing 1] -right-> [Yes]

@enduml

See also:

Regards,
Th.

commented May 27, 2025 by dylan (120 points)

Many thanks for this Th.!

Your links showed me that the order of components in left-to-right direction is not "literal" to what I list in the code. Very confusing but key to understanding.

Your tweaks definitely ordered the sub-components and components correctly, but the layout was not as useful as before. So I tweaked these lines:

[Thing 1] -right-> [An Index]
[Thing 1] -right-> [Yes]

to this:

[Thing 1] --> [An Index]
[Thing 1] --> [Yes]

The layout is much better, but the order was reversed again!

But this time I simply switched the order of the first two sub-components and all the rest reverted to correct order.

I guess tweaking like this is the way to do it? Or is there any method in the madness?!

Thanks again.

commented May 27, 2025 by dylan (120 points)

And here is the result:

image

...