You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改PlantUML(C4)中Container组件的宽高?以message_bus为例

调整PlantUML C4中Message Bus容器的尺寸方法

要修改示例代码里message_bus组件的宽高,直接在它的Container定义中添加$width和$height参数,指定具体尺寸即可(支持像素、厘米等单位,默认单位为像素)。

修改后的核心代码片段

// 给message_bus指定宽200像素、高100像素
Container(message_bus, "Message Bus", "RabbitMQ", "Transport for business events", $width=200, $height=100)

完整修改后的代码

@startuml "messagebus"
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
' uncomment the following line and comment the first to use locally
' !include C4_Container.puml

AddElementTag("microService", $shape=EightSidedShape(), $bgColor="CornflowerBlue", $fontColor="white", $legendText="micro service\neight sided")
AddElementTag("storage", $shape=RoundedBoxShape(), $bgColor="lightSkyBlue", $fontColor="white")

Person(customer, Customer, "A customer")

System_Boundary(c1, "Customer Information") {
    Container(app, "Customer Application", "Javascript, Angular", "Allows customers to manage their profile")
    Container(customer_service, "Customer Service", "Java, Spring Boot", "The point of access for customer information", $tags = "microService")
    // 这里添加了$width和$height参数调整尺寸
    Container(message_bus, "Message Bus", "RabbitMQ", "Transport for business events", $width=200, $height=100)
    Container(reporting_service, "Reporting Service", "Ruby", "Creates normalised data for reporting purposes", $tags = "microService")
    Container(audit_service, "Audit Service", "C#/.NET", "Provides organisation-wide auditing facilities", $tags = "microService")
    ContainerDb(customer_db, "Customer Database", "Oracle 12c", "Stores customer information", $tags = "storage")
    ContainerDb(reporting_db, "Reporting Database", "MySQL", "Stores a normalized version of all business data for ad hoc reporting purposes", $tags = "storage")
    Container(audit_store, "Audit Store", "Event Store", "Stores information about events that have happened", $tags = "storage")
}

@enduml

如果需要批量调整同类型组件的尺寸,也可以通过AddElementTag给标签添加$width和$height属性,但针对单个组件直接设置参数是最直接的方式。

内容的提问来源于stack exchange,提问作者JavaDevS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 04:43:19