Platform
Resources
Pricing
Sign in
Get started
Observable
The end-to-end solution for building and hosting better data apps, dashboards, and reports.
Workspace
Fork
Unlisted
By
Mike Bostock
Edited
Dec 1, 2022
1 fork
1 star
Insert cell
Insert cell
Plot
.
plot
(
{
marginLeft
:
100
,
marginRight
:
40
,
marks
:
[
Plot
.
barX
(
olympians
,
Plot
.
groupY
(
{
x
:
"count"
}
,
{
y
:
"sport"
,
sort
:
{
y
:
"x"
,
reverse
:
true
}
}
)
)
,
Plot
.
text
(
olympians
,
Plot
.
groupY
(
{
x
:
"count"
,
text
:
"count"
}
,
{
frameAnchor
:
"left"
,
dx
:
3
,
y
:
"sport"
,
sort
:
{
y
:
"x"
,
reverse
:
true
}
}
)
)
]
}
)
Insert cell
Plot
.
plot
(
{
marginLeft
:
100
,
marginRight
:
40
,
marks
:
[
Plot
.
barX
(
olympians
,
groupBySport
(
)
)
,
Plot
.
text
(
olympians
,
groupBySport
(
{
text
:
"count"
}
,
{
frameAnchor
:
"left"
,
dx
:
3
}
)
)
]
}
)
Insert cell
function
groupBySport
(
outputs
,
options
)
{
return
Plot
.
groupY
(
{
x
:
"count"
,
...
outputs
}
,
{
y
:
"sport"
,
sort
:
{
y
:
"x"
,
reverse
:
true
}
,
...
options
}
)
;
}
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
groupBySport
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML