Platform
Resources
Pricing
Sign in
Contact us
Fil
Vocateur.
Workspace
Fork
Public
2 collections
By
Fil
Edited
Jun 19, 2022
5 forks
61 stars
Insert cell
Insert cell
{
const
el
=
html
`<div style="width: 100%; height: 600px;"></div>`
;
yield
el
;
ForceGraph3D
(
)
(
el
)
.
height
(
600
)
.
linkWidth
(
4
)
.
linkOpacity
(
0.5
)
.
graphData
(
gData
)
.
d3Force
(
"radius"
,
forceRadius
(
gData
.
nodes
,
320
)
)
;
}
Insert cell
gData
=
{
// Random tree
const
N
=
300
;
return
{
nodes
:
[
...
Array
(
N
)
.
keys
(
)
]
.
map
(
(
i
)
=>
(
{
id
:
i
}
)
)
,
links
:
[
...
Array
(
N
)
.
keys
(
)
]
.
filter
(
(
id
)
=>
id
)
.
map
(
(
id
)
=>
(
{
source
:
id
,
target
:
Math
.
round
(
Math
.
random
(
)
*
(
id
-
1
)
)
}
)
)
}
;
}
Insert cell
function
forceRadius
(
nodes
,
R
=
1
)
{
return
(
)
=>
{
for
(
const
n
of
nodes
)
{
const
r
=
Math
.
hypot
(
n
.
x
,
n
.
y
,
n
.
z
)
;
const
u
=
Math
.
pow
(
r
?
Math
.
sqrt
(
R
/
r
)
:
1
,
0.05
)
;
n
.
x
*=
u
;
n
.
y
*=
u
;
n
.
z
*=
u
;
}
}
;
}
Insert cell
ForceGraph3D
=
require
(
"3d-force-graph"
)
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
Listed in...
3D
Fil
Graphs
Fil
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
forceRadius
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ForceGraph3D
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML