D2 diagram

 https://d2lang.com/tour/

https://play.d2lang.com/


x -> y: hello world

This declares a connection between two shapes, x and y, with the label, hello world.

-> connection 

-- also connection 

key : label if missing label key = label 

A: Christmas {shape: cylinder}


Shape

just text makes rectangle shape with label eg:

dog 

gives dog in rectangle


You can also use semicolons to define multiple shapes on the same line

By default, a shape's type is rectangle. To specify otherwise, provide the field shape in key

dog:pitbull

dog.shape:cloud


circle,square maintain 1:1 ratio


Connectors

<->  bi dir arrow

<-  left arrow

-> right arrow

--  no arrow 


connection can have label in between

box1 -- box2 : conncetion label


Repeated connections do not override existing connections. They declare new ones.

For readability, it may look more natural to define multiple connection in a single line.


To override the default arrowhead shape or give a label next to arrowheads, define a special shape on connections named source-arrowhead and/or target-arrowhead.

using { } 


Arrowhead options

triangle (default)

Can be further styled as style.filled: false.

arrow (like triangle but pointier)

diamond

Can be further styled as style.filled: true.

circle

Can be further styled as style.filled: true.

box

Can be further styled as style.filled: true.

cf-one, cf-one-required (cf stands for crows foot)

cf-many, cf-many-required

cross


It's recommended the arrowhead labels be kept short. They do not go through autolayout for optimal positioning like regular labels do, so long arrowhead labels are more likely to collide with surrounding objects.


container 

dog.cat 


You can avoid repeating containers by creating nested maps.


Sometimes you want to reference something outside of the container from within. The underscore (_) refers to parent.

for rest see site this is just for memory/history