Platform
Resources
Pricing
Sign in
Get started
Visnu Pitiyanuvath
Workspace
Fork
Public
By
Visnu Pitiyanuvath
Edited
Dec 13
1 star
13
Insert cell
Insert cell
Insert cell
Insert cell
rarity
=
d3
.
scalePoint
(
[
"Legendary"
,
"Rare"
,
"Uncommon"
,
"Common"
]
,
[
0.2
,
1
]
)
Insert cell
list
=
(
aspect
)
=>
d3
.
sort
(
all
.
filter
(
(
d
)
=>
d
.
aspects
[
0
]
?.
attributes
.
name
===
aspect
&&
d
.
type
.
attributes
.
name
!==
"Base"
)
,
(
d
)
=>
[
"Leader"
,
"Unit"
,
"Event"
,
"Upgrade"
]
.
indexOf
(
d
.
type
.
attributes
.
name
)
,
(
d
)
=>
d
.
title
)
Insert cell
Insert cell
cards
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
cards
=
{
if
(
cached
)
{
yield
set
.
file
.
json
(
)
;
}
else
{
let
cards
=
[
]
;
let
page
=
1
;
while
(
true
)
{
const
res
=
await
fetch
(
`https://cors-proxy.visnup.vercel.app/admin.starwarsunlimited.com/api/card-list?locale=en&orderBy[expansion][id]=asc&sort[0]=type.sortValue%3Aasc%2C%20expansion.sortValue%3Adesc%2CcardNumber%3Aasc%2C&filters[$and][0][variantOf][id][$null]=true&filters[$and][1][expansion][id][$in][0]=${
set
.
id
}&aspectMethod=0&traitMethod=0&pagination[page]=${
page
}&pagination[pageSize]=250`
)
;
const
json
=
await
res
.
json
(
)
;
cards
=
cards
.
concat
(
json
.
data
.
map
(
(
d
)
=>
d
.
attributes
)
)
;
yield
cards
;
if
(
json
.
data
.
length
===
0
)
break
;
page
++
;
}
}
}
Insert cell
sets
=
[
{
name
:
"Spark of Rebellion"
,
file
:
FileAttachment
(
"sor@3.json"
)
,
id
:
2
}
,
{
name
:
"Shadows of the Galaxy"
,
file
:
FileAttachment
(
"shd@5.json"
)
,
id
:
8
}
,
{
name
:
"Twilight of the Republic"
,
file
:
FileAttachment
(
"twi.json"
)
,
id
:
18
}
]
Insert cell
all
=
(
await
Promise
.
all
(
sets
.
map
(
(
d
)
=>
d
.
file
.
json
(
)
)
)
)
.
flat
(
)
.
map
(
(
d
)
=>
{
for
(
const
[
k
,
v
]
of
Object
.
entries
(
d
)
)
if
(
v
&&
typeof
v
===
"object"
&&
"data"
in
v
)
d
[
k
]
=
v
.
data
;
return
d
;
}
)
Insert cell
d3
.
csvFormat
(
all
)
Insert cell
grouped
=
d3
.
rollup
(
all
.
filter
(
(
d
)
=>
d
.
type
.
attributes
.
name
!==
"Base"
&&
d
.
reprintOf
===
null
)
,
(
r
)
=>
Math
.
ceil
(
r
.
length
/
12
)
,
(
d
)
=>
d
.
aspects
[
0
]
?.
attributes
.
name
)
Insert cell
d3
.
sum
(
grouped
.
values
(
)
)
Insert cell
pages
=
912
/
12
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
aspect
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rarity
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
list
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
cards
File attachments
cards.json
JSON
collection.csv
CSV
sor.json
JSON
shd.json
JSON
shd@1.json
JSON
shd@2.json
JSON
sor@1.json
JSON
shd@3.json
JSON
shd@4.json
JSON
sor@2.json
JSON
twi.json
JSON
shd@5.json
JSON
sor@3.json
JSON
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
cached
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cards
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sets
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
all
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
grouped
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
pages
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML