D2 3. Customization - swkim0128/PARA GitHub Wiki


type: D2 archive: false

Layouts

Layout engines

Direction

Dagre

Reference

Pros

Cons

Gallery

ELK

Reference

Pros

Cons

Gallery

TALA

Reference

Pros

Cons

Gallery

Themes

They apply to special shapes like tables too

Setting theme on the CLI

Dark theme

Special themes

Styles

Style keywords

Opacity

Stroke

Fill

Fill Pattern

Stroke Width

Stroke Dash

Border Radius

Shadow

3D

Multiple

Double Border

Font

Font Size

Font Color

Animated

Bold, italic, underline

Root

Dimensions

Sketch (Hand-drawn)

Interactive

Tooltips

Links

Layouts

D2λŠ” λ‹€μ–‘ν•œ λ ˆμ΄μ•„μ›ƒ 엔진을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ ˆμ΄μ•„μ›ƒ μ—”μ§„μ˜ 선택은 전체 λ‹€μ΄μ–΄κ·Έλž¨μ— 큰 영ν–₯을 λ―ΈμΉ©λ‹ˆλ‹€. 각 λ ˆμ΄μ•„μ›ƒμ€ νŠΉμ • ν‚€μ›Œλ“œμ— λŒ€ν•œ 지원도 λ‹€λ₯΄κ²Œ κ°€μ§€κ³  μžˆμŠ΅λ‹ˆλ‹€. μš°λ¦¬λŠ” 일관성을 μœ μ§€ν•˜κΈ° μœ„ν•΄ μ΅œμ„ μ„ λ‹€ν•˜μ§€λ§Œ, μ΅œμ’…μ μœΌλ‘œλŠ” μš°λ¦¬κ°€ 직접 λ§Œλ“  λ ˆμ΄μ•„μ›ƒ 엔진에 κ°€μž₯ λ§Žμ€ μ œμ–΄κΆŒμ΄ 있으며, λ‹€λ₯Έ λ ˆμ΄μ•„μ›ƒ 엔진이 μ§€μ›ν•˜λŠ” κ²ƒμœΌλ‘œ μ œν•œλ©λ‹ˆλ‹€.

Layout engines

  • dagre (κΈ°λ³Έκ°’): 계측적 λ ˆμ΄μ•„μ›ƒμ„ μƒμ„±ν•˜λŠ” λΉ λ₯Έ λ°©ν–₯μ„± κ·Έλž˜ν”„ λ ˆμ΄μ•„μ›ƒ μ—”μ§„μž…λ‹ˆλ‹€. Graphviz의 DOT μ•Œκ³ λ¦¬μ¦˜μ„ κΈ°λ°˜μœΌλ‘œν•©λ‹ˆλ‹€.
  • ELK: λ°©ν–₯ κ·Έλž˜ν”„ λ ˆμ΄μ•„μ›ƒ μ—”μ§„μž…λ‹ˆλ‹€. dagre보닀 더 μ„±μˆ™ν•˜λ©° (파트 νƒ€μž„ ν•™μˆ  연ꡬ νŒ€μœΌλ‘œ μœ μ§€ κ΄€λ¦¬λ˜κ³  있음) 졜근 버전이 μΆœμ‹œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.
  • TALA: μ†Œν”„νŠΈμ›¨μ–΄ μ•„ν‚€ν…μ²˜ λ‹€μ΄μ–΄κ·Έλž¨μ— νŠΉν™”λœ μƒˆλ‘œμš΄ λ ˆμ΄μ•„μ›ƒ μ—”μ§„μž…λ‹ˆλ‹€.

μ›ν•˜λŠ” λ ˆμ΄μ•„μ›ƒ 엔진을 μ„ νƒν•˜κ³  λ‹€μ΄μ–΄κ·Έλž¨μ— κ°€μž₯ μ ν•©ν•œ 것을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 각각의 엔진은 κ·Έλ“€λ§Œμ˜ μž₯단점이 있으며, μžμ„Έν•œ λ‚΄μš©μ€ κ°œλ³„ νŽ˜μ΄μ§€λ₯Ό λ°©λ¬Έν•˜μ—¬ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

μ‚¬μš© κ°€λŠ₯ν•œ λ ˆμ΄μ•„μ›ƒμ„ 보렀면, d2 layout을 μ‹€ν–‰ν•΄λ³΄μ„Έμš”. 각 λ ˆμ΄μ•„μ›ƒ 엔진은 νŠΉμ • ꡬ성 κ°€λŠ₯ν•œ ν”Œλž˜κ·Έλ₯Ό κ°€μ§ˆ μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” d2 layout [μ—”μ§„]을 μ‹€ν–‰ν•˜μ—¬ 찾을 수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, d2 layout dagreμž…λ‹ˆλ‹€.

μ‚¬μš©ν•  λ ˆμ΄μ•„μ›ƒμ„ μ§€μ •ν•˜λ €λ©΄, ν”Œλž˜κ·Έ --layout=dagreλ₯Ό μ„€μ •ν•˜κ±°λ‚˜ ν™˜κ²½ λ³€μˆ˜ $D2_LAYOUT=dagre둜 μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Direction

λ‹€μŒ 쀑 ν•˜λ‚˜λ₯Ό μ„ νƒν•˜μ—¬ λ‹€μ΄μ–΄κ·Έλž¨μ΄ ν–₯ν•˜λŠ” λ°©ν–₯을 λͺ…μ‹œμ μœΌλ‘œ μ œμ–΄ν•˜λ €λ©΄ direction을 μ„€μ •ν•˜μ‹­μ‹œμ˜€.

Important

OPTIONSupdownrightleft

direction: right
x -> y -> z: hello

Dagre

Dagre is D2's default layout engine.

Reference

https://github.com/dagrejs/dagre

Pros

  • 맀우 λΉ λ¦…λ‹ˆλ‹€.
  • μ „νˆ¬ κ²½ν—˜μ„ κ²ͺμ—ˆμŠ΅λ‹ˆλ‹€ (MermaidJSκ°€ Dagreλ₯Ό μ‚¬μš©ν•˜μ—¬ ν”Œλ‘œμš°μ°¨νŠΈλ₯Ό λ§Œλ“  λ•λΆ„μž…λ‹ˆλ‹€).
  • 일반적으둜 쒋은 κ²°κ³Όλ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.
  • μ•Œκ³ λ¦¬μ¦˜μ˜ 이둠은 Graphvizλ₯Ό κ΅¬λ™ν•˜λŠ” λ…Όλ¬Έμž…λ‹ˆλ‹€.
  • κ³„μΈ΅ν˜• λ ˆμ΄μ•„μ›ƒμ„ 잘 λ Œλ”λ§ν•©λ‹ˆλ‹€.

Cons

  • μœ μ§€λ³΄μˆ˜λ˜μ§€ μ•ŠμŒ. 2018년에 개발이 μ€‘λ‹¨λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
  • λ•Œλ•Œλ‘œ μ΄μƒν•œ μ—£μ§€ λΌμš°νŒ… 결정을 λ‚΄λ¦½λ‹ˆλ‹€. (https://github.com/dagrejs/dagre/issues/256).
  • λ ˆμ΄μ•„μ›ƒ μ•Œκ³ λ¦¬μ¦˜μ€ μ—„κ²©ν•˜κ²Œ 계측적이며, κΈ°λ³Έ λ‹€μ΄μ–΄κ·Έλž¨μ΄ 계측적이지 μ•Šλ”λΌλ„ κ·Έλ ‡μŠ΅λ‹ˆλ‹€.
  • ν•œ μ»¨ν…Œμ΄λ„ˆ μžμ‹μ΄ λ‹€λ₯Έ μ»¨ν…Œμ΄λ„ˆ (λ˜λŠ” λ‹€λ₯Έ μ»¨ν…Œμ΄λ„ˆ μžμ‹)에 λŒ€ν•œ 지원이 dagreμ—μ„œλŠ” 기본적으둜 μ§€μ›λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. D2λŠ” shim을 μΆ”κ°€ν•˜μ—¬ μž‘λ™μ‹œμΌ°μ§€λ§Œ, shim으둜 인해 핡심 μ•Œκ³ λ¦¬μ¦˜ κ³ λ € 사항이 λˆ„λ½λ  수 μžˆμŠ΅λ‹ˆλ‹€.
  • 닀쀑 μ„Έκ·Έλ¨ΌνŠΈ μ—£μ§€ κ²½λ‘œλŠ” 직각이 μ•„λ‹Œ κ³‘μ„ μž…λ‹ˆλ‹€. 아름닡지 μ•Šμ€ κΌ¬κΌ¬λ¬΄λ£©ν•œ 선이 될 수 μžˆμŠ΅λ‹ˆλ‹€.

Gallery

!Untitled 25.png

!Untitled 1 5.png

ELK

ELKλŠ” μ„±μˆ™ν•œ κ³„μΈ΅ν˜• λ ˆμ΄μ•„μ›ƒμœΌλ‘œ, Kiel의 Christian Albrechts λŒ€ν•™κ΅μ—μ„œ ν•™μˆ  연ꡬ 그룹에 μ˜ν•΄ ν™œλ°œν•˜κ²Œ μœ μ§€λ³΄μˆ˜λ˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

Reference

https://www.eclipse.org/elk/reference.html

Pros

  • κΉ”λ”ν•˜κ³  μ§κ΅ν•œ 경둜.
  • 맀우 μ‚¬μš©μž μ •μ˜ κ°€λŠ₯.
  • λΉ λ¦…λ‹ˆλ‹€.
  • ꡐ차점 μ΅œμ†Œν™”μ— λŠ₯ν•©λ‹ˆλ‹€.
  • μ»¨ν…Œμ΄λ„ˆ κ°„ λΌμš°νŒ…μ„ μžμ—°μŠ€λŸ½κ²Œ μ§€μ›ν•˜μ—¬ dagre보닀 더 잘 μ²˜λ¦¬ν•©λ‹ˆλ‹€.
  • 정기적인 μ—…λ°μ΄νŠΈλ‘œ μ§€μ†μ μœΌλ‘œ κ°œμ„  μ€‘μž…λ‹ˆλ‹€.

Cons

  • dagre와 λ§ˆμ°¬κ°€μ§€λ‘œ μ—„κ²©ν•œ 계측 κ΅¬μ‘°μž…λ‹ˆλ‹€.
  • 일뢀 κ²½λ‘œμ—λŠ” λΆˆν•„μš”ν•œ ꡽은 뢀뢄이 μžˆμŠ΅λ‹ˆλ‹€.
  • λŒ€μΉ­μ„±μ„ κ³ λ €ν•œ μ΅œμ†Œν•œμ˜ λ””μžμΈμž…λ‹ˆλ‹€.

Gallery

!Untitled 2 5.png

!Untitled 3 5.png

TALA

ν…ŒλΌμŠ€νŠΈλŸ­νŠΈμ—μ„œ κ°œλ°œν•œ μ „μš© λ ˆμ΄μ•„μ›ƒ μ—”μ§„μœΌλ‘œ, μ†Œν”„νŠΈμ›¨μ–΄ μ•„ν‚€ν…μ²˜ λ‹€μ΄μ–΄κ·Έλž¨μ„ μœ„ν•΄ νŠΉλ³„νžˆ μ„€κ³„λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

TALAλŠ” 100% 무료 및 μ˜€ν”ˆ μ†ŒμŠ€μΈ D2와 μ „μš©, 폐쇄 μ†ŒμŠ€μΈ TALA κ°„μ˜ κΉ¨λ—ν•œ ꡬ뢄을 μœ μ§€ν•˜κΈ° μœ„ν•΄ λ³„λ„λ‘œ μ„€μΉ˜ν•΄μ•Ό ν•©λ‹ˆλ‹€. λ‹€μŒμ—μ„œ λ‹€μš΄λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€: https://github.com/terrastruct/tala.

Reference

https://terrastruct.com/tala/

Pros

  • 일반적으둜 직ꡐ λ ˆμ΄μ•„μ›ƒ μ—”μ§„μœΌλ‘œμ„œ TALAλŠ” 계측 ꡬ쑰, 트리 λ˜λŠ” λ°©μ‚¬ν˜•κ³Ό 같은 ν•˜λ‚˜μ˜ μœ ν˜•μ— μ œν•œλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 기본적으둜 비계측적 λ ˆμ΄μ•„μ›ƒμ˜ 경우, TALAλŠ” 인간이 ν™”μ΄νŠΈ λ³΄λ“œμ— 그릴 λ•Œμ²˜λŸΌ λ‹€μ΄μ–΄κ·Έλž¨μ„ 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.
  • λŒ€μΉ­μ„ κ³ λ €ν•˜κ³  μ„ ν˜Έν•©λ‹ˆλ‹€.
  • μ»¨ν…Œμ΄λ„ˆμ— λŒ€ν•œ 일등급 κ³ λ € 사항이 μžˆμŠ΅λ‹ˆλ‹€.
  • direction은 μ»¨ν…Œμ΄λ„ˆλ§ˆλ‹€ μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  • nearλŠ” λ‹€λ₯Έ λͺ¨μ–‘에 κ°€κΉŒμ΄ μ§€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  • sql_table 연결은 μ •ν™•ν•œ 행을 κ°€λ¦¬ν‚΅λ‹ˆλ‹€.
  • μž₯애물을 ν”Όν•˜κΈ° μœ„ν•΄ 동적 λ ˆμ΄λΈ” μœ„μΉ˜ 지정이 κ°€λŠ₯ν•©λ‹ˆλ‹€.

Cons

  • λ¬΄λ£Œκ°€ μ•„λ‹™λ‹ˆλ‹€.
  • κΈ°λ³Έ μ•Œκ³ λ¦¬μ¦˜μ˜ 차이 (λ§Žμ€ νœ΄λ¦¬μŠ€ν‹± 검색 반볡이 μ΅œμ’… λ ˆμ΄μ•„μ›ƒμ— 수렴되고 계측 ꡬ쑰와 같은 μ œμ•½μ‘°κ±΄μ˜ λΆ€μž¬)둜 인해 λ‹€λ₯Έ λ ˆμ΄μ•„μ›ƒ 엔진보닀 훨씬 λŠλ¦½λ‹ˆλ‹€.
  • λ‹€λ₯Έ λ ˆμ΄μ•„μ›ƒ μ—”μ§„κ³Ό λΉ„κ΅ν•˜μ—¬ 비ꡐ적 μƒˆλ‘œμš΄ μ—”μ§„μž…λ‹ˆλ‹€. λŒ€μ•ˆ λ ˆμ΄μ•„μ›ƒ μ—”μ§„μ˜ 10년에 λΉ„ν•΄ 운영 기간은 μ•½ 1λ…„ μ •λ„μž…λ‹ˆλ‹€.
  • λ‹€λ₯Έ λ ˆμ΄μ•„μ›ƒ 엔진보닀 더 λ¬΄μž‘μœ„μ μž…λ‹ˆλ‹€. λ ˆμ΄λΈ”μ˜ μž‘μ€ 변경이 μ™„μ „νžˆ λ‹€λ₯Έ λ ˆμ΄μ•„μ›ƒμœΌλ‘œ μ΄μ–΄μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€.

Gallery

!Untitled 4 3.png

!Untitled 5 3.png

Themes

D2μ—λŠ” λ‹€μ–‘ν•œ ν…Œλ§ˆκ°€ μžˆμ–΄μ„œ λ‹€μ΄μ–΄κ·Έλž¨μ„ 전문적이고 λΈ”λ‘œκ·Έλ‚˜ μœ„ν‚€μ— μ‚½μž…ν•˜κΈ° μ ν•©ν•˜κ²Œ λ§Œλ“€μ–΄ μ€λ‹ˆλ‹€.

They apply to special shapes like tables too

Setting theme on the CLI

μ‚¬μš©ν•œ ν…Œλ§ˆλ₯Ό μ§€μ •ν•˜λ €λ©΄, ν”Œλž˜κ·Έ -t, --theme을 μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

d2 -t 101 input.d2

ν™˜κ²½ λ³€μˆ˜λ₯Ό μ‚¬μš©ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

D2_THEME=101 d2 input.d2

μ‚¬μš© κ°€λŠ₯ν•œ ν…Œλ§ˆλ₯Ό 보렀면 λ‹€μŒμ„ μ‹€ν–‰ν•˜μ‹­μ‹œμ˜€.

d2 themes

Dark theme

닀크 ν…Œλ§ˆλŠ” κΈ°λ³Έκ°’μœΌλ‘œ μ„€μ •λ˜μ§€ μ•ŠμœΌλ―€λ‘œ μ‚¬μš©μžμ˜ μ‹œμŠ€ν…œ ν™˜κ²½ 섀정이 라이트 λͺ¨λ“œμΈμ§€ 닀크 λͺ¨λ“œμΈμ§€μ— 관계없이 λ‹€μ΄μ–΄κ·Έλž¨μ΄ λ™μΌν•˜κ²Œ λ³΄μž…λ‹ˆλ‹€.

Important

INFO이 λ¬Έμ„œμ˜ λͺ¨λ“  λ‹€μ΄μ–΄κ·Έλž¨μ€ μ–΄λ‘μš΄ ν…Œλ§ˆλ‘œ κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ‹œμŠ€ν…œ ν™˜κ²½ μ„€μ •μ—μ„œ 밝은 ν…Œλ§ˆμ™€ μ–΄λ‘μš΄ ν…Œλ§ˆλ₯Ό μ „ν™˜ν•΄λ³΄λ©΄ μ–΄λ–»κ²Œ λ³€ν™”ν•˜λŠ”μ§€ ν™•μΈν•΄λ³΄μ„Έμš”.

μ‚¬μš©μž μ‹œμŠ€ν…œ ν™˜κ²½μ„€μ •μ΄ μ–΄λ‘μš΄ ν…Œλ§ˆμΈ 경우 λ‹€μ΄μ–΄κ·Έλž¨μ΄ μ μ‘ν•˜κ³  μ–΄λ‘μš΄ ν…Œλ§ˆλ‘œ μ „ν™˜λ˜λ„λ‘ ν•˜λ €λ©΄ λ‹€μŒ ν”Œλž˜κ·Έλ₯Ό μ§€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

d2 --dark-theme 200 input.d2

일반적인 ν…Œλ§ˆμ™€ λ§ˆμ°¬κ°€μ§€λ‘œ, 이것은 ν™˜κ²½ λ³€μˆ˜λ‘œ μ„€μ •ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

D2_DARK_THEME=200 d2 input.d2

Important

INFOν…Œλ§ˆλŠ” 밝은(light) ν…Œλ§ˆμ™€ μ–΄λ‘μš΄(dark) ν…Œλ§ˆλ‘œ λ”°λ‘œ λΆ„λ₯˜λ©λ‹ˆλ‹€. ν•˜μ§€λ§Œ 당신은 μ–΄λ‘μš΄ ν…Œλ§ˆ IDλ₯Ό theme에 μ „λ‹¬ν•˜μ—¬ 항상 μ–΄λ‘μš΄ λͺ¨λ“œλ₯Ό μ‚¬μš©ν•˜λŠ” λ‹€μ΄μ–΄κ·Έλž¨μ„ λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€(λ˜λŠ” κ·Έ λ°˜λŒ€λ‘œ, μ–΄λ‘μš΄ λͺ¨λ“œ μ‚¬μš©μžλ“€μ—κ²Œ 놀라움을 쀄 수 μžˆμŠ΅λ‹ˆλ‹€).

μ–΄λ‘μš΄ ν…Œλ§ˆμ˜ μ˜ˆμ‹œμž…λ‹ˆλ‹€. (μ΄λ―Έμ§€μ΄λ―€λ‘œ μ‹œμŠ€ν…œ ν™˜κ²½ 섀정에 따라 λ³€κ²½λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€).

Special themes

νŠΉμ • νŠΉλ³„ν•œ ν…Œλ§ˆλŠ” 색상 μ΄μƒμ˜ 역할을 ν•©λ‹ˆλ‹€.

예λ₯Ό λ“€μ–΄ Terminal ν…Œλ§ˆλ₯Ό μ μš©ν•˜λ©΄ λ‹€μŒ 속성이 κΈ°λ³Έκ°’μœΌλ‘œ μ„€μ •λ©λ‹ˆλ‹€:

  • λͺ¨λ“  라벨에 λŒ€λ¬Έμžκ°€ μ μš©λ©λ‹ˆλ‹€.
  • ν…Œλ‘λ¦¬ 반경이 μ—†μŠ΅λ‹ˆλ‹€.
  • 고정폭 글꼴이 μ‚¬μš©λ©λ‹ˆλ‹€.
  • λͺ¨λ“  μ»¨ν…Œμ΄λ„ˆμ˜ fill-pattern이 dots둜 μ„€μ •λ©λ‹ˆλ‹€.
  • κ°€μž₯ λ°”κΉ₯μͺ½ μ»¨ν…Œμ΄λ„ˆλŠ” double-borderκ°€ true둜 μ„€μ •λ©λ‹ˆλ‹€.

!Untitled 6 3.png

μ•„λž˜ λ‹€μ΄μ–΄κ·Έλž¨μ— λŒ€ν•œ μ†ŒμŠ€ μ½”λ“œ (ELK둜 λ Œλ”λ§ 됨)λŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€. νŠΉλ³„ν•œ ν…Œλ§ˆκ°€ λ‹€λ₯Έ 기본값을 μ‚¬μš©ν•˜κΈ° λ•Œλ¬Έμ— 라벨의 케이싱과 같은 λ‹€μ΄μ–΄κ·Έλž¨μ—μ„œ λͺ…ν™•ν•œ 속성이 μ†ŒμŠ€μ—λŠ” λ‚˜νƒ€λ‚˜μ§€ μ•ŠλŠ” 것을 μ£Όλͺ©ν•˜μ„Έμš”.

network: {
  cell tower: {
    satellites: {
      shape: stored_data
      style.multiple: true
    }

    transmitter

    satellites -> transmitter: send
    satellites -> transmitter: send
    satellites -> transmitter: send
  }

  online portal: {
    ui: {shape: hexagon}
  }

  data processor: {
    storage: {
      shape: cylinder
      style.multiple: true
    }
  }

  cell tower.transmitter -> data processor.storage: phone logs
}

user: {
  shape: person
  width: 130
}

user -> network.cell tower: make call
user -> network.online portal.ui: access {
  style.stroke-dash: 3
}

api server -> network.online portal.ui: display
api server -> logs: persist
logs: {shape: page; style.multiple: true}

network.data processor -> api server

Styles

λ§Œμ•½ λͺ¨μ–‘μ˜ μŠ€νƒ€μΌμ„ μ»€μŠ€ν„°λ§ˆμ΄μ¦ˆν•˜λ €λ©΄, λ‹€μŒ μ˜ˆμ•½μ–΄λ“€μ€ style ν•„λ“œμ— 섀정될 수 μžˆμŠ΅λ‹ˆλ‹€.

μ•„λž˜λŠ” λͺ¨λ“  μœ νš¨ν•œ μŠ€νƒ€μΌ λͺ©λ‘μž…λ‹ˆλ‹€. 이 λͺ©λ‘μ€ κΈ°μ€€ λ‹€μ΄μ–΄κ·Έλž¨μ— 각각 μ μš©λ©λ‹ˆλ‹€.

Important

NOTEλ‹€μŒ SVGλŠ” direction: right둜 λ Œλ”λ§λ˜μ§€λ§Œ μš”μ•½μ„ μœ„ν•΄ ν‘œμ‹œλœ μŠ€ν¬λ¦½νŠΈμ—μ„œ μƒλž΅λ©λ‹ˆλ‹€.

Style keywords

Opacity

0κ³Ό 1 μ‚¬μ΄μ˜ 뢀동 μ†Œμˆ˜μ  κ°’

x -> y: hi {
  style: {
    opacity: 0.4
  }
}
x.style.opacity: 0
y.style.opacity: 0.7

Stroke

색 이름 λ˜λŠ” 16μ§„μˆ˜ μ½”λ“œ

x -> y: hi {
  style: {
    stroke: deepskyblue
  }
}
# We need quotes for hex otherwise it gets interpreted as comment
x.style.stroke: "\#f4a261"

sql_tableκ³Ό class에 λŒ€ν•΄μ„œλŠ”, strokeλŠ” body에 fill둜 μ μš©λ©λ‹ˆλ‹€. (header의 fill을 μ œμ–΄ν•˜κΈ° μœ„ν•΄ fill이 이미 μ‚¬μš©λ˜κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.)

Fill

CSS 색상 이름 λ˜λŠ” 16μ§„μˆ˜ μ½”λ“œμž…λ‹ˆλ‹€.

x -> y: hi
x.style.fill: "\#f4a261"
y.style.fill: honeydew

sql_tableκ³Ό class에 λŒ€ν•΄ fill은 헀더에 μ μš©λ©λ‹ˆλ‹€.

Want transparent?

x: {
  y
  y.style.fill: transparent
}
x.style.fill: PapayaWhip

Fill Pattern

Available patterns:

  • dots
  • lines
  • grain
style.fill-pattern: dots
x -> y: hi
x.style.fill-pattern: lines
y.style.fill-pattern: grain

Stroke Width

Integer between 1 and 15.

x -> y: hi {
  style: {
    stroke-width: 8
  }
}
x.style.stroke-width: 1

Stroke Dash

Integer between 0 and 10.

x -> y: hi {
  style: {
    stroke-dash: 3
  }
}
x.style.stroke-dash: 5

Border Radius

Integer between 0 and 20.

x -> y: hi
x.style.border-radius: 3
y.style.border-radius: 8

Important

INFOborder-radiusλŠ” 연결에도 μž‘λ™ν•˜μ—¬ λͺ¨μ„œλ¦¬κ°€ μ–Όλ§ˆλ‚˜ λ‘₯κΈ€κ²Œ ν‘œμ‹œλ˜λŠ”μ§€λ₯Ό μ œμ–΄ν•©λ‹ˆλ‹€. μ΄λŠ” μ½”λ„ˆλ₯Ό μ‚¬μš©ν•˜λŠ” λ ˆμ΄μ•„μ›ƒ μ—”μ§„ (예: ELK)μ—λ§Œ 적용되며, λ¬Όλ‘  μ½”λ„ˆκ°€μžˆλŠ” μ—°κ²°μ—λ§Œ 영ν–₯을 λ―ΈμΉ©λ‹ˆλ‹€.

Shadow

true or false.

x -> y: hi
x.style.shadow: true

3D

true or false.

x -> y: hi
x.style.3d: true

Multiple

true or false.

x -> y: hi
x.style.multiple: true

Double Border

true or false.

x -> y: hi
x.style.double-border: true
y.shape: circle
y.style.double-border: true

Font

ν˜„μž¬ μœ μΌν•œ μ˜΅μ…˜μ€ monoλ₯Ό μ§€μ •ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. μΆ”κ°€ μ˜΅μ…˜μ€ κ³§ μ œκ³΅λ©λ‹ˆλ‹€.

x -> y: hi {
  style: {
    font: mono
  }
}
x.style.font: mono
y.style.font: mono

Font Size

Integer between 8 and 100.

x -> y: hi {
  style: {
    font-size: 28
  }
}
x.style.font-size: 8
y.style.font-size: 55

Font Color

CSS color name or hex code.

x -> y: hi {
  style: {
    font-color: red
  }
}
x.style.font-color: "\#f4a261"

sql_tableκ³Όclass에 λŒ€ν•΄μ„œλŠ” 헀더 ν…μŠ€νŠΈμ—λ§Œ font-colorκ°€ μ μš©λ©λ‹ˆλ‹€ (ν…Œλ§ˆλŠ” 본문의 λ‹€λ₯Έ 색상을 μ œμ–΄ν•©λ‹ˆλ‹€).

Animated

true or false.

x -> y: hi {
  style.animated: true
}

Bold, italic, underline

true or false.

x -> y: hi {
  style: {
    bold: true
  }
}
x.style.underline: true
y.style.italic: true
# By default, shape labels are bold. Bold has precedence over italic, so unbold to ee
# italic style
y.style.bold: false

Root

일뢀 μŠ€νƒ€μΌμ€ 루트 λ ˆλ²¨μ—μ„œ μ μš©λ©λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, λ‹€μ΄μ–΄κ·Έλž¨ 배경색을 μ„€μ •ν•˜λ €λ©΄ style.fill을 μ‚¬μš©ν•˜μ‹­μ‹œμ˜€.

ν˜„μž¬ μ§€μ›λ˜λŠ” ν‚€μ›Œλ“œ 집합은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€:

  • fill: λ‹€μ΄μ–΄κ·Έλž¨ 배경색
  • stroke: λ‹€μ΄μ–΄κ·Έλž¨ μ£Όμœ„μ˜ ν”„λ ˆμž„
  • stroke-width
  • stroke-dash
  • double-border: 두 개의 ν”„λ ˆμž„μœΌλ‘œ μΈκΈ°μžˆλŠ” ν”„λ ˆμž„ 방법 쀑 ν•˜λ‚˜μž…λ‹ˆλ‹€.
x -> y: hi
style: {
  fill: LightBlue
  stroke: FireBrick
  stroke-width: 2
}

Important

INFO이 λ¬Έμ„œμ˜ λͺ¨λ“  λ‹€μ΄μ–΄κ·Έλž¨μ€ pad=0둜 λ Œλ”λ§λ©λ‹ˆλ‹€. 당신이 λ‹€μ΄μ–΄κ·Έλž¨μ˜ ν”„λ ˆμž„μ„ λ§Œλ“€κΈ° μœ„ν•΄ strokeλ₯Ό μ‚¬μš©ν•˜κ³  μžˆλ‹€λ©΄, νŒ¨λ”©μ„ μΆ”κ°€ν•˜λ €κ³  ν•  κ²ƒμž…λ‹ˆλ‹€.

Dimensions

λŒ€λΆ€λΆ„μ˜ λ„ν˜•μ—μ„œ λ„ˆλΉ„와 λ†’이λ₯Ό μ§€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Important

INFOμ΄λŸ¬ν•œ ν‚€μ›Œλ“œλŠ” μ»¨ν…Œμ΄λ„ˆμ— μ„€μ •ν•  수 μ—†μŠ΅λ‹ˆλ‹€. μ™œλƒν•˜λ©΄ μ»¨ν…Œμ΄λ„ˆλŠ” μžμ‹ μš”μ†Œμ— 맞게 크기가 쑰절되기 λ•Œλ¬Έμž…λ‹ˆλ‹€.

direction: right

small jerry: "" {
  shape: image
  icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
  width: 200
  height: 200
}

med jerry: "" {
  shape: image
  icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
  width: 300
  height: 300
}

big jerry: "" {
  shape: image
  icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
  width: 500
  height: 400
}

big jerry -> med jerry -> small jerry

Sketch (Hand-drawn)

D2 can render diagrams to give the aesthetic of a hand-drawn sketch.

  • In Terrastruct, you can enable this with hand-drawn mode.
  • If you're using the CLI, this is enabled by the -sketch flag.
  • https://play.d2lang.com supports this as well.

Interactive

Tooltips

νˆ΄νŒμ€ 마우슀 ν˜Έλ²„ μ‹œ λ‚˜νƒ€λ‚˜λŠ” ν…μŠ€νŠΈμž…λ‹ˆλ‹€. 두 κ°€μ§€ λͺ©μ μ΄ μžˆμŠ΅λ‹ˆλ‹€:

  1. 보쑰 μ»¨ν…μŠ€νŠΈ μΆ”κ°€
    • 객체에 μ„€λͺ…을 μΆ”κ°€ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€. λͺ¨λ“  μ‚¬λžŒμ΄ ν•„μš”ν•œ 것은 μ•„λ‹ˆμ§€λ§Œ μΆ”κ°€ 정보가 ν•„μš”ν•œ μ‚¬λžŒλ“€μ€ μ•‘μ„ΈμŠ€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  2. 깔끔함
    • λ‹€μ΄μ–΄κ·Έλž¨μ΄ μ§€μ €λΆ„ν•΄μ§€κ³  μžˆμŠ΅λ‹ˆλ‹€. 더 λ§Žμ€ ν…μŠ€νŠΈλ₯Ό μΆ”κ°€ν•˜λŠ” λŒ€μ‹ , 일뢀λ₯Ό νˆ΄νŒμ— 넣을 수 μžˆμŠ΅λ‹ˆλ‹€.
x: { tooltip: Total abstinence is easier than perfect moderation }
y: { tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS! }
x -> y

이것을 μ‹œλ„ν•΄λ³΄μ„Έμš”. x와 y μœ„μ— 마우슀λ₯Ό 올리면 툴팁이 μžˆλŠ” μ•„μ΄μ½˜μ΄ λ‚˜νƒ€λ‚©λ‹ˆλ‹€.

정적 ν˜•μ‹(PNG와 같은)으둜 내보낼 λ•Œ D2λŠ”

  1. λͺ¨λ“  μ•„μ΄μ½˜μ΄ 번호둜 λ°”λ€λ‹ˆλ‹€.
  2. 각 쀄이 λ²ˆν˜Έμ— ν•΄λ‹Ήν•˜λŠ” 뢀둝이 μΆ”κ°€λ©λ‹ˆλ‹€.

Links

Links are like tooltips, except you click to go to an external link.

x: I'm a Mac {
  link: https://apple.com
}
y: And I'm a PC {
  link: https://microsoft.com
}
x -> y: gazoontite

Important

INFOIf you are using the Terrastruct app, you can link to other boards through their path.x.link: Overview.My Service.Stuff

⚠️ **GitHub.com Fallback** ⚠️