Skip to content

Commit 606e214

Browse files
authored
Merge pull request #333: document render options and Dagre spacing
- sent from alixander's Codex
2 parents ee4e9dd + b6b378e commit 606e214

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎docs/tour/dagre.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@ Dagre is D2's default layout engine.
1212

1313
[https://github.com/dagrejs/dagre](https://github.com/dagrejs/dagre)
1414

15+
## Spacing
16+
17+
On D2's development branch (`master`), you can set Dagre spacing in
18+
`vars.d2-config.data`. These source options will be available in the next release.
19+
20+
```d2
21+
vars: {
22+
d2-config: {
23+
data: {
24+
dagre-nodesep: 120
25+
dagre-edgesep: 40
26+
}
27+
}
28+
}
29+
30+
gateway -> api
31+
gateway -> worker
32+
```
33+
34+
`dagre-nodesep` controls the spacing between nodes in the same rank (default 60
35+
pixels). `dagre-edgesep` controls the spacing between edges (default 20 pixels).
36+
Both take nonnegative whole numbers. Each value in the diagram takes precedence
37+
over its corresponding CLI flag, `--dagre-nodesep` or `--dagre-edgesep`.
38+
1539
## Pros
1640

1741
- Very fast.

‎docs/tour/vars.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,30 @@ In other words, if you call `D2_PAD=2 d2 --theme=1 input.d2`, it doesn't matter
8282
the command.
8383
:::
8484

85+
### Output scale and SVG appendix
86+
87+
On D2's development branch (`master`), you can set `scale` and `force-appendix`
88+
in the diagram. These source options will be available in the next release.
89+
90+
```d2
91+
vars: {
92+
d2-config: {
93+
scale: 0.5
94+
force-appendix: true
95+
}
96+
}
97+
98+
checkout: Checkout API {
99+
tooltip: Validates orders before payment
100+
}
101+
```
102+
103+
`scale: 0.5` renders at half size. Use `-1` for automatic sizing, which lets an SVG
104+
fit its container. `force-appendix: true` adds numbered notes for links and tooltips
105+
to SVG exports, including animated boards. PNG exports already include the notes.
106+
To export the same diagram at its natural size without the SVG appendix, run
107+
`d2 --scale=1 --force-appendix=false input.d2 output.svg`.
108+
85109
:::info `data`
86110
`data` is an anything-goes map of key-value pairs. This is used in contexts where
87111
third-party software read configuration, such as when D2 is used as a library, or D2 is

0 commit comments

Comments
 (0)