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

PlantUML时序图:如何在activate前添加空白间隔?

如何在PlantUML时序图的activate语句前添加空白间隔?

这个需求和Stack Overflow上的同类问题类似,但核心区别是:我们不需要在箭头后加空白,而是要在activate(也就是图中下方的蓝色竖线)语句之前插入空白间隔。

示例PlantUML代码

actor Client
participant Server

Client->Server: before space, with no activate

||45|| 

Client->Server: after space with no activate

Client->Server: before space with activate

||45|| 

activate Client #blue
Client->Server: after activate with space

deactivate Client

Client->Server: after deactivate

当前生成效果

当前效果

期望实现效果

期望效果

解决方案

要在activate语句前添加空白,你可以通过隐藏自消息占位的方式实现:在activate前插入一条隐藏的自消息,让PlantUML在箭头和蓝色竖线之间留出空白。修改后的代码如下:

actor Client
participant Server

Client->Server: before space, with no activate

||45|| 

Client->Server: after space with no activate

Client->Server: before space with activate

||45|| 

# 添加隐藏自消息创建空白间隔
Client->Client: #hidden
activate Client #blue
Client->Server: after activate with space

deactivate Client

Client->Server: after deactivate

原理是:隐藏的自消息不会在图中显示,但会占据对应的垂直空间,从而让后续的activate蓝色竖线从该位置开始,自然和上一条业务箭头拉开距离。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 19:51:15