d2 icon indicating copy to clipboard operation
d2 copied to clipboard

Feature request: Sequence diagram notes over multiple actors

Open bentinata opened this issue 2 years ago • 6 comments

Currently, d2 only have notes on actors. Would be nice to have multiline notes. Provided example on PlantUML and Mermaid.

PlantUML

@startuml
A -> B : hello
note over A, B
{
  "message": "hello"
}
end note
@enduml

Mermaid

Mermaid cannot do multiline notes as easy as PlantUML.

sequenceDiagram
    A->>+B: hello
    Note over A, B: { "message": "hello" }

bentinata avatar Mar 13 '23 04:03 bentinata

Just noticed the discussion section. Should I one and link this issue?

bentinata avatar Mar 13 '23 04:03 bentinata

@bentinata no this is fine =). thank you for bringing it up!

i don't really understand the use case though. like this looks like a note for the message instead of the actors.

alixander avatar Mar 13 '23 04:03 alixander

https://play.d2lang.com/?l=&script=AjvXSqE4tbA0NS85NT4lMzG9KDGXy5HLiYsrLT8_KbHISkGpWiFGKTe1uDgxPTVGyUohRikjNScnP0ZJoVZJoZpLQcFRQddOwclKASzMVcvFBROAKszDYwAXIAAA__8%3D&

bo-ku-ra avatar Mar 13 '23 12:03 bo-ku-ra

@alixander

I usually use notes on PlantUML as some sort of place to put sample payload. Let me know if this is a wrong sequence diagram usage.

I also tried @bo-ku-ra suggestion.

d2

Playground.

bentinata avatar Mar 13 '23 15:03 bentinata

I think I have the same issue or question as the original poster. Is there any way to add code to a sequence diagram?

In the examples above a piece of JSON is requested, but it could be anything really, some HTML, or any other message format.

Is there a way to add a piece of code to a sequence diagram, using any of D2lang's available syntax?

For example is there any way to add this

message: |json
  { "message": "hello" }
|

Image

to a sequence diagram anywhere? In a message, on a note, etc.

None of the links to https://play.d2lang.com in this thread are working for me, they all render two empty white boxes when they're clicked. So I just added the example code snippet and resulting image as a screenshot to this message.

jish avatar Feb 28 '25 23:02 jish

i do not like d2's sequence_diagram. (i especially hate that 'Spans' needs to be named) therefore, i usually use mermaid.

forced workaround in d2

shape: sequence_diagram

a: |json
  { "message": "hello" }
|
b

a.note: |json
  { "message": "hello" }
|

message: |json
  { "message": "hello" }
| {
  style.stroke-width: 1
  a -- b: "" {style.stroke-width: 0}
}

bo-ku-ra avatar Mar 01 '25 00:03 bo-ku-ra