Platform
Resources
Pricing
Sign in
Get started
Devin Bayly
Workspace
Fork
Public
By
Devin Bayly
Edited
Nov 7, 2023
Fork of
Exploring the openalex UA cluster users data
Insert cell
Insert cell
viewof
file
=
Inputs
.
file
(
{
label
:
"Data"
}
)
Insert cell
data
=
file
.
json
(
)
Insert cell
users
=
data
.
reduce
(
(
acc
,
cur
)
=>
{
if
(
acc
[
cur
.
ua_name
]
==
undefined
)
{
acc
[
cur
.
ua_name
]
=
[
]
;
}
acc
[
cur
.
ua_name
]
.
push
(
cur
)
;
return
acc
;
}
,
{
}
)
Insert cell
sorted_names
=
{
let
order_arr
=
[
]
;
let
i
=
0
;
for
(
let
key
in
users
)
{
order_arr
.
push
(
[
i
,
users
[
key
]
.
length
]
)
;
i
+=
1
;
}
let
sorted
=
order_arr
.
sort
(
(
a
,
b
)
=>
{
return
a
[
1
]
-
b
[
1
]
;
}
)
;
let
names
=
Object
.
keys
(
users
)
;
return
names
.
map
(
(
e
,
i
)
=>
{
return
names
[
sorted
[
i
]
[
0
]
]
;
}
)
;
}
Insert cell
top_users
=
sorted_names
.
slice
(
-
15
)
.
map
(
(
e
)
=>
(
{
name
:
e
,
counts
:
users
[
e
]
.
length
}
)
)
Insert cell
Plot
.
plot
(
{
title
:
"Publications by top cluster users in 2016-2022"
,
marginLeft
:
150
,
insetRight
:
25
,
y
:
{
reverse
:
true
}
,
grid
:
true
,
marks
:
[
Plot
.
barX
(
top_users
,
{
x
:
"counts"
,
y
:
"name"
,
tip
:
true
,
sort
:
{
y
:
"x"
}
}
)
,
Plot
.
ruleX
(
[
0
]
)
,
Plot
.
textX
(
top_users
,
{
x
:
"counts"
,
y
:
"name"
,
dx
:
15
,
text
:
"counts"
}
)
]
}
)
Insert cell
Plot
.
plot
(
{
x
:
{
ticks
:
d3
.
range
(
2016
,
2023
)
,
tickFormat
:
d3
.
format
(
"d"
)
}
,
y
:
{
domain
:
[
0
,
1800
]
}
,
grid
:
true
,
marks
:
[
Plot
.
rectY
(
data
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"publication_year"
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
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
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
file
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
users
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sorted_names
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
top_users
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