Platform
Resources
Pricing
Sign in
Get started
Harrison Shoff
Created visx and the Airbnb JS style guide
Workspace
Fork
Public
By
Harrison Shoff
Edited
Jul 13, 2023
1 fork
4 stars
Insert cell
Insert cell
viewof
height
=
html
`<input type=range min=0 max=1000 step=1 value=400>`
Insert cell
viewof
numPoints
=
html
`<input type=range min=20 max=1000 step=10 value=600>`
Insert cell
html
`
<div id="root"></div>
`
Insert cell
TileBackground
=
(
props
)
=>
{
return
(
React
.
createElement
(
React
.
Fragment
,
{
}
,
[
React
.
createElement
(
Gradient
.
GradientPinkRed
,
{
key
:
"gradient"
,
id
:
"pink-gradient"
}
)
,
React
.
createElement
(
"rect"
,
{
key
:
'rect'
,
...
props
}
)
]
)
)
;
}
Insert cell
Dots
=
(
)
=>
{
return
(
React
.
createElement
(
React
.
Fragment
,
{
}
,
points
.
map
(
(
point
,
i
)
=>
{
return
(
React
.
createElement
(
"circle"
,
{
key
:
`dot-${
i
}`
,
fill
:
'#f6c431'
,
cx
:
xScale
(
x
(
point
)
)
,
cy
:
yScale
(
y
(
point
)
)
,
r
:
i
%
3
===
0
?
3
:
2
}
)
)
;
}
)
)
)
;
}
Insert cell
Chart
=
React
.
createElement
(
"svg"
,
{
width
,
height
}
,
[
React
.
createElement
(
TileBackground
,
{
key
:
'bg'
,
fill
:
"url(#pink-gradient)"
,
width
,
height
,
rx
:
14
}
)
,
React
.
createElement
(
Dots
,
{
key
:
'dots'
}
)
]
)
Insert cell
ReactDOM
.
render
(
Chart
,
document
.
getElementById
(
"root"
)
)
Insert cell
Shape
=
import
(
'https://cdn.skypack.dev/@visx/shape@3.3.0?min'
)
Insert cell
MockData
=
import
(
'https://unpkg.com/@visx/mock-data@3.3.0/esm/index.js?module'
)
Insert cell
Gradient
=
import
(
'https://cdn.skypack.dev/@visx/gradient@3.3.0?min'
)
Insert cell
Scale
=
import
(
'https://cdn.skypack.dev/@visx/scale@3.3.0?min'
)
Insert cell
React
=
import
(
'https://cdn.skypack.dev/react@18.2.0?min'
)
Insert cell
ReactDOM
=
import
(
'https://cdn.skypack.dev/react-dom@18.2.0?min'
)
Insert cell
x
=
d
=>
d
[
0
]
Insert cell
y
=
d
=>
d
[
1
]
Insert cell
z
=
d
=>
d
[
2
]
Insert cell
points
=
MockData
.
genRandomNormalPoints
(
numPoints
)
.
filter
(
(
d
,
i
)
=>
{
return
i
<
numPoints
;
}
)
Insert cell
xScale
=
Scale
.
scaleLinear
(
{
domain
:
[
1.3
,
2.2
]
,
range
:
[
0
,
width
]
,
clamp
:
true
}
)
Insert cell
yScale
=
Scale
.
scaleLinear
(
{
domain
:
[
0.75
,
1.6
]
,
range
:
[
height
,
0
]
,
clamp
:
true
}
)
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
height
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
TileBackground
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Dots
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Chart
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Shape
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
MockData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Gradient
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Scale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
React
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ReactDOM
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
y
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
z
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
points
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML