Platform
Resources
Pricing
Sign in
Get started
pbogden
Workspace
Fork
Public
By
pbogden
Edited
Jul 22, 2024
Insert cell
Insert cell
Insert cell
// Plot.binX() returns an object with has a transform method, any unconsumed options that you give it, and other stuff.
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"weight"
,
checkitout
:
"Hello, world!"
}
)
Insert cell
// The facets array for the case of no faceting is just an array of the array indices.
facets
=
[
Array
.
from
(
Array
(
olympians
.
length
)
.
keys
(
)
)
]
Insert cell
// .transform(data, facets) returns an object with data and facets that containing arrays of binned data and a new facets array
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"weight"
}
)
.
transform
(
olympians
,
facets
)
Insert cell
Insert cell
d3bins
=
d3
.
bin
(
)
.
thresholds
(
80
)
.
value
(
(
d
)
=>
d
.
weight
)
(
olympians
)
Insert cell
Plot
.
rectY
(
d3bins
,
{
x1
:
"x0"
,
x2
:
"x1"
,
y2
:
"length"
}
)
.
plot
(
{
x
:
{
round
:
true
}
,
y
:
{
grid
:
true
}
}
)
Insert cell
Plot
.
plot
(
{
x
:
{
round
:
true
}
,
y
:
{
grid
:
true
,
label
:
`whatever`
}
,
tip
:
true
,
marks
:
[
Plot
.
rectY
(
olympians
,
Plot
.
binX
(
{
y
:
"sum"
,
title
:
"count"
}
,
{
x
:
"weight"
,
y
:
"weight"
,
inset
:
0
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Plot
.
rectY
(
olympians
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"weight"
,
inset
:
0
,
tip
:
true
}
)
)
.
initialize
(
)
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
facets
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3bins
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML