Skip to content

Commit

Permalink
docs on label near
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Jul 24, 2023
1 parent 8d7dc81 commit 0b22917
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/tour/positions.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,46 @@ Server.Online Model Server

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-explanation.svg2')}}></div>

## Label and icon positioning

The `near` can be nested to `label` and `icon` to specify their positions.

```d2
direction: right
x -> y
x: worker {
label.near: top-center
icon: https://icons.terrastruct.com/essentials%2F005-programmer.svg
icon.near: outside-top-right
}
y: profits {
label.near: bottom-right
icon: https://icons.terrastruct.com/essentials%2Fprofits.svg
icon.near: outside-top-left
}
```

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-label-icon.svg2')}}></div>

:::info Extra values

When positioning labels and icons, in addition to the values that `near` can take
elsewhere, an `outside-` prefix can be added to specify positioning outside the bounding
box of the shape.

`outside-top-left`, `outside-top-center`, `outside-top-right`,

`outside-left-center`, `outside-right-center`,

`outside-bottom-left`, `outside-bottom-center`, `outside-bottom-right`


Note that `outside-left-center` is a different order than `center-left`.
:::


## Near objects

:::info
Expand Down
14 changes: 14 additions & 0 deletions static/d2/near-label-icon.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
direction: right
x -> y

x: worker {
label.near: top-center
icon: https://icons.terrastruct.com/essentials%2F005-programmer.svg
icon.near: outside-top-right
}

y: profits {
label.near: bottom-right
icon: https://icons.terrastruct.com/essentials%2Fprofits.svg
icon.near: outside-top-left
}
Loading

0 comments on commit 0b22917

Please sign in to comment.