Platform
Resources
Pricing
Sign in
Get started
Gregor Aisch
CTO @Datawrapper & proud @nytgraphics alumni
Workspace
Fork
Published
By
Gregor Aisch
Edited
Mar 3, 2021
2 stars
Insert cell
md
`# label placement`
Insert cell
Insert cell
orientation
=
getOrientation
(
dx
,
dy
)
Insert cell
viewof
dx
=
Range
(
[
-
100
,
100
]
,
{
value
:
0
,
label
:
"dx"
}
)
Insert cell
viewof
dy
=
Range
(
[
-
100
,
100
]
,
{
value
:
0
,
label
:
"dy"
}
)
Insert cell
angle
=
1
-
(
(
Math
.
atan2
(
dy
,
dx
)
-
Math
.
PI
/
4
)
/
Math
.
PI
)
*
2
Insert cell
angleRound
=
Math
.
round
(
angle
)
Insert cell
angleDeg
=
angle
/
Math
.
PI
*
180
Insert cell
import
{
Range
}
from
"@observablehq/inputs"
Insert cell
getOrientation
=
function
(
dx
,
dy
)
{
return
[
'bottom-end'
,
'bottom-start'
,
'top-start'
,
'top-end'
]
[
Math
.
round
(
1
-
(
(
Math
.
atan2
(
dy
,
dx
)
-
Math
.
PI
/
4
)
/
Math
.
PI
)
*
2
)
]
;
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
orientation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dx
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dy
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
angle
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
angleRound
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
angleDeg
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getOrientation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML