Lines in diagram to another rectangle all mangled, how to fix

0 votes
asked Apr 28, 2025 in Question / help by arcomber (160 points)
With the following UML, the lines into the Bus box all seem to attempt to join the left side of the bus box

@startuml
rectangle "System" as sys {
  rectangle "motherboard" as mboard {
     rectangle "CPU" as cpu {
       url of cpu is [[https://en.wikipedia.org/wiki/Central_processing_unit]]
     }
     rectangle "memory" as mem {
       url of mem is [[https://en.wikipedia.org/wiki/Computer_memory]]
     }
     rectangle "GPU" as gpu {
       url of gpu [[https://en.wikipedia.org/wiki/Graphics_processing_unit]]
     }
     rectangle "Disk" as disk {
       url of disk is [[https://en.wikipedia.org/wiki/Mass_storage]]
     }
     rectangle "keyboard" as kb {
       url of kb is [[https://en.wikipedia.org/wiki/Computer_keyboard]]
     }
  }
}

rectangle "Bus" as bus {
     rectangle "PCIe Bus" as pcie {
       url of pcie is [[https://en.wikipedia.org/wiki/PCI_Express]]
     }
     rectangle "USB" as usb {
       url of usb is [[https://en.wikipedia.org/wiki/USB]]
     }
}

cpu -- bus
mem -- bus
gpu -- bus
disk -- bus
kb -- bus
@enduml

But if I remove the pcie and usb then it looks fine, eg:

rectangle "Bus" as bus {

}

Then the lines are sort of spread out and it looks a lot nicer.  But I need the inner pcie and usb rectangles so can't remove those.

1 Answer

+1 vote
answered Apr 28, 2025 by The-Lu (89,080 points)
selected Apr 28, 2025 by arcomber
 
Best answer

Hello A.,

That's seems due to the version of Graphviz.

From:

Here is a proposal (adding pseudo label and hidden arrow...) as:

@startuml
rectangle "System" as sys {
  rectangle "motherboard" as mboard {
     rectangle "CPU" as cpu {
       url of cpu is [[https://en.wikipedia.org/wiki/Central_processing_unit]]
     }
     rectangle "memory" as mem {
       url of mem is [[https://en.wikipedia.org/wiki/Computer_memory]]
     }
     rectangle "GPU" as gpu {
       url of gpu [[https://en.wikipedia.org/wiki/Graphics_processing_unit]]
     }
     rectangle "Disk" as disk {
       url of disk is [[https://en.wikipedia.org/wiki/Mass_storage]]
     }
     rectangle "keyboard" as kb {
       url of kb is [[https://en.wikipedia.org/wiki/Computer_keyboard]]
     }
  }
}

rectangle " " as b {
     label "Bus" as bus
     rectangle "PCIe Bus" as pcie {
       url of pcie is [[https://en.wikipedia.org/wiki/PCI_Express]]
     }
     rectangle "USB" as usb {
       url of usb is [[https://en.wikipedia.org/wiki/USB]]
     }
}
cpu --> bus
mem --> bus
gpu --> bus
disk --> bus
kb --> bus

bus -[hidden]- pcie
bus -[hidden]- usb
@enduml

If that can help,
Regards,
Th.

commented Apr 28, 2025 by The-Lu (89,080 points)

Hello A.,

Another workaround will be to use sub-diagram as:

@startuml
rectangle "System" as sys {
  rectangle "motherboard" as mboard {
     rectangle "CPU" as cpu {
       url of cpu is [[https://en.wikipedia.org/wiki/Central_processing_unit]]
     }
     rectangle "memory" as mem {
       url of mem is [[https://en.wikipedia.org/wiki/Computer_memory]]
     }
     rectangle "GPU" as gpu {
       url of gpu [[https://en.wikipedia.org/wiki/Graphics_processing_unit]]
     }
     rectangle "Disk" as disk {
       url of disk is [[https://en.wikipedia.org/wiki/Mass_storage]]
     }
     rectangle "keyboard" as kb {
       url of kb is [[https://en.wikipedia.org/wiki/Computer_keyboard]]
     }
  }
}

rectangle bus #white [{{
     title "Bus"
     rectangle "PCIe Bus" as pcie {
       url of pcie is [[https://en.wikipedia.org/wiki/PCI_Express]]
     }
     rectangle "USB" as usb {
       url of usb is [[https://en.wikipedia.org/wiki/USB]]
     }
}}]

cpu -- bus
mem -- bus
gpu -- bus
disk -- bus
kb -- bus
@enduml

Enjoy,
Regards,
Th.

...