Platform
Resources
Pricing
Sign in
Get started
Brianna Wilson
data journalist, gardener, engineer
Workspace
Fork
Public
DVS-workshop
By
Brianna Wilson
Edited
Oct 29, 2023
2 forks
4 stars
DVS-workshop
Canvas setup - random scatter plot
STARTER: Canvas setup - random scatter plot
WebGL/Three.js setup - random scatterplot
STARTER: WebGL/Three.js setup - random scatterplot
WebGL/Three.js 3D force network graph
STARTER: WebGL/Three.js 3D force network graph
Canvas Animated Plots
STARTER: Canvas Animated Plots
Insert cell
Insert cell
Insert cell
Insert cell
graphDiv
=
html
`<div id="3d-graph" width="600" height="600"></div>`
Insert cell
Insert cell
Insert cell
ForceGraph3D
=
require
(
'3d-force-graph'
)
Insert cell
THREE
=
import
(
"three@0.158.0"
)
Insert cell
UnrealBloomPass
=
(
await
import
(
"three@0.158.0/examples/jsm/postprocessing/UnrealBloomPass.js"
)
)
.
UnrealBloomPass
Insert cell
Insert cell
numberOfPoints
=
500
Insert cell
data
=
{
let
data
=
{
nodes
:
[
...
Array
(
numberOfPoints
)
.
keys
(
)
]
.
map
(
i
=>
(
{
id
:
i
}
)
)
,
links
:
[
...
Array
(
numberOfPoints
)
.
keys
(
)
]
.
filter
(
id
=>
id
)
.
map
(
id
=>
(
{
source
:
id
,
target
:
Math
.
round
(
Math
.
random
(
)
*
(
id
-
1
)
)
}
)
)
}
return
data
}
Insert cell
Insert cell
Graph
=
ForceGraph3D
(
)
(
document
.
getElementById
(
'3d-graph'
)
)
.
backgroundColor
(
'#000003'
)
.
graphData
(
data
)
.
nodeLabel
(
'id'
)
.
enableNodeDrag
(
false
)
Insert cell
Insert cell
bloomPass
=
{
const
bloomPass
=
new
UnrealBloomPass
(
)
bloomPass
.
strength
=
2
bloomPass
.
radius
=
1
return
bloomPass
}
Insert cell
Graph
.
postProcessingComposer
(
)
.
addPass
(
bloomPass
)
Insert cell
// If you want to run from a .html file
// <!DOCTYPE html>
// <html>
// <head>
// <meta charset="UTF-8">
// <meta name="viewport" content="width=device-width, initial-scale=1.0">
// <title>WebGL Data Visualization</title>
// <style>
// body { margin: 0; }
// canvas { display: block; }
// </style>
// <script src="https://unpkg.com/3d-force-graph"></script>
// </head>
// <body>
// <div id="3d-graph"></div>
// <script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
// <script type="module">
// import { UnrealBloomPass } from 'https://unpkg.com/three/examples/jsm/postprocessing/UnrealBloomPass.js'
// const Graph = ForceGraph3D()
// (document.getElementById('3d-graph'))
// .backgroundColor('#000003')
// .jsonUrl('https://raw.githubusercontent.com/vasturiano/3d-force-graph/master/example/datasets/miserables.json')
// .nodeLabel('id')
// .enableNodeDrag(false)
// //.nodeAutoColorBy('group')
// // Add glow effect with three.js postprocessing
// const bloomPass = new UnrealBloomPass()
// bloomPass.strength = 1
// bloomPass.radius = 0.8
// Graph.postProcessingComposer().addPass(bloomPass)
// // camera orbit
// let angle = 0
// const distance = 700
// </script>
// </body>
// </html>
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
graphDiv
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ForceGraph3D
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
THREE
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
UnrealBloomPass
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numberOfPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Graph
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
bloomPass
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML