PageSourceSearch

https://d2lang.com/assets/js/d18b07d8.0743bdc5.js

js d2lang.com collected 2026-09-25 14:55:54 UTC 5,429 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["6535"],{82954:function(e,r,n){n.r(r),n.d(r,{frontMatter:()=>i,default:()=>h,toc:()=>c,metadata:()=>s,assets:()=>a,contentTitle:()=>d});var s=JSON.parse('{"id":"tour/elk","title":"ELK","description":"\uD83D\uDD17 Gallery","source":"@site/docs/tour/elk.md","sourceDirName":"tour","slug":"/tour/elk","permalink":"/tour/elk","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{},"sidebar":"tourSidebar","previous":{"title":"Dagre","permalink":"/tour/dagre"},"next":{"title":"TALA","permalink":"/tour/tala"}}'),t=n(85893),l=n(50065);let i={},d="ELK",a={},c=[{value:"Reference",id:"reference",level:2},{value:"Algorithms",id:"algorithms",level:2},{value:"Pros",id:"pros",level:2},{value:"Cons",id:"cons",level:2}];function o(e){let r={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.header,{children:(0,t.jsx)(r.h1,{id:"elk",children:"ELK"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:(0,t.jsx)(r.a,{href:"/examples/elk",children:"\uD83D\uDD17 Gallery"})})}),"\n",(0,t.jsxs)(r.p,{children:["ELK is a mature layout engine, actively maintained by an academic research group at\n",(0,t.jsx)(r.a,{href:"https://www.rtsys.informatik.uni-kiel.de/en/team",children:"Christian Albrechts University in\nKiel"}),"."]}),"\n",(0,t.jsx)(r.h2,{id:"reference",children:"Reference"}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.a,{href:"https://www.eclipse.org/elk/reference.html",children:"https://www.eclipse.org/elk/reference.html"})}),"\n",(0,t.jsx)(r.h2,{id:"algorithms",children:"Algorithms"}),"\n",(0,t.jsxs)(r.p,{children:["ELK has several layout algorithms. D2 uses ",(0,t.jsx)(r.code,{children:"layered"})," by default. To choose another one,\npass ",(0,t.jsx)(r.code,{children:"--elk-algorithm"})," along with ",(0,t.jsx)(r.code,{children:"--layout=elk"}),"."]}),"\n",(0,t.jsx)(r.p,{children:"The main choices for connected diagrams are:"}),"\n",(0,t.jsxs)(r.table,{children:[(0,t.jsx)(r.thead,{children:(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.th,{children:"Algorithm"}),(0,t.jsx)(r.th,{children:"Description"})]})}),(0,t.jsxs)(r.tbody,{children:[(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.td,{children:(0,t.jsx)(r.code,{children:"layered"})}),(0,t.jsx)(r.td,{children:"The default. Arranges shapes in layers, with orthogonal connections."})]}),(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.td,{children:(0,t.jsx)(r.code,{children:"force"})}),(0,t.jsx)(r.td,{children:"Spreads shapes out using simulated attraction and repulsion."})]}),(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.td,{children:(0,t.jsx)(r.code,{children:"stress"})}),(0,t.jsx)(r.td,{children:"Places shapes closer together when there are shorter paths between them."})]}),(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.td,{children:(0,t.jsx)(r.code,{children:"mrtree"})}),(0,t.jsx)(r.td,{children:"Arranges a tree in levels."})]}),(0,t.jsxs)(r.tr,{children:[(0,t.jsx)(r.td,{children:(0,t.jsx)(r.code,{children:"radial"})}),(0,t.jsx)(r.td,{children:"Arranges a tree in circles around its root."})]})]})]}),"\n",(0,t.jsx)(r.p,{children:"For example:"}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-shell",children:"d2 --layout=elk --elk-algorithm=force input.d2 force.svg\nd2 --layout=elk --elk-algorithm=stress input.d2 stress.svg\nd2 --layout=elk --elk-algorithm=radial tree.d2 radial.svg\n"})}),"\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"radial"})," expects a tree. For example, ",(0,t.jsx)(r.code,{children:"tree.d2"})," could contain:"]}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-d2",children:"a -> b\na -> c\nc -> d\n"})}),"\n",(0,t.jsxs)(r.p,{children:["The pros and cons below describe the default ",(0,t.jsx)(r.code,{children:"layered"})," algorithm. Other algorithms have\ndifferent routing and feature support."]}),"\n",(0,t.jsx)(r.h2,{id:"pros",children:"Pros"}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsx)(r.li,{children:"Clean, orthogonal routes."}),"\n",(0,t.jsx)(r.li,{children:"Highly customizable."}),"\n",(0,t.jsx)(r.li,{children:"Fast."}),"\n",(0,t.jsx)(r.li,{children:"Good at minimizing crossings."}),"\n",(0,t.jsx)(r.li,{children:"Natively supports container to container routing, handling these better than dagre."}),"\n",(0,t.jsx)(r.li,{children:"Undergoing active improvements with regular releases."}),"\n",(0,t.jsx)(r.li,{children:"Routes SQL tables with exact columns."}),"\n"]}),"\n",(0,t.jsx)(r.h2,{id:"cons",children:"Cons"}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsx)(r.li,{children:"Strictly hierarchical, like dagre."}),"\n",(0,t.jsx)(r.li,{children:"Some routes have unnecessary bends."}),"\n",(0,t.jsx)(r.li,{children:"Minimal consideration for symmetry."}),"\n"]})]})}function h(e={}){let{wrapper:r}={...(0,l.a)(),...e.components};return r?(0,t.jsx)(r,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},50065:function(e,r,n){n.d(r,{Z:()=>d,a:()=>i});var s=n(67294);let t={},l=s.createContext(t);function i(e){let r=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function d(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),s.createElement(l.Provider,{value:r},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.