Platform
Resources
Pricing
Sign in
Get started
novotny1akub
Workspace
Fork
Public
By
novotny1akub
Edited
May 1, 2023
Insert cell
Insert cell
Insert cell
import
{
athletes
}
from
"@observablehq/hello-inputs"
Insert cell
Inputs
.
table
(
athletes
)
Insert cell
Insert cell
athletes
.
map
(
d
=>
(
{
name
:
d
.
name
,
height
:
d
.
height
,
weight
:
d
.
weight
}
)
)
// select, rename
.
map
(
d
=>
(
{
...
d
,
bodyMassIndex
:
d
.
weight
/
d
.
height
**
2
}
)
)
// mutate
.
filter
(
d
=>
d
.
bodyMassIndex
>
45
&&
d
.
height
)
// filtering out nulls from height
Insert cell
Insert cell
d3
.
flatRollup
(
athletes
,
v
=>
d3
.
mean
(
v
,
d
=>
d
.
height
)
,
d
=>
d
.
nationality
,
d
=>
d
.
sex
)
.
map
(
(
[
nationality
,
sex
,
avg
]
)
=>
(
{
nationality
,
sex
,
avg
}
)
)
Insert cell
Insert cell
d3
.
flatRollup
(
athletes
,
v
=>
(
{
avgHeight
:
d3
.
mean
(
v
,
d
=>
d
.
height
)
,
avgWeight
:
d3
.
mean
(
v
,
d
=>
d
.
weight
)
}
)
,
d
=>
d
.
nationality
,
d
=>
d
.
sex
)
.
map
(
(
[
nation
,
sport
,
Calcs
]
)
=>
(
{
nation
,
sport
,
...
Calcs
}
)
)
Insert cell
Insert cell
viewof
selectSport
=
{
const
values
=
athletes
.
map
(
d
=>
d
.
sport
)
;
return
Inputs
.
select
(
values
,
{
label
:
"Select one"
,
unique
:
true
,
multiple
:
true
}
)
}
Insert cell
selectSport
Insert cell
athletes
.
filter
(
d
=>
!
selectSport
.
length
||
selectSport
.
includes
(
d
.
sport
)
)
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
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
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
Edit
Add comment
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
selectSport
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