Platform
Resources
Pricing
Sign in
Get started
Gus's Workspace
Workspace
Fork
Unlisted
By
Gus
Edited
Nov 29, 2023
Insert cell
Insert cell
import
{
DuckDBClient
}
from
"@cmudig/duckdb"
Insert cell
data
=
fetch
(
'https://data.cityofnewyork.us/resource/vfnx-vebw.json'
)
.
then
(
res
=>
res
.
json
(
)
)
.
then
(
data
=>
data
.
map
(
item
=>
(
{
...
item
,
x
:
Number
(
item
.
x
)
,
y
:
Number
(
item
.
y
)
}
)
)
)
Insert cell
db
=
DuckDBClient
.
of
(
{
data
}
)
Insert cell
Insert cell
db
Filter
Columns
36
Sort
Slice
0–1000
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
colors
=
[
]
Insert cell
{
const
_colors
=
new
Set
(
)
;
data
.
forEach
(
item
=>
item
.
primary_fur_color
&&
_colors
.
add
(
item
.
primary_fur_color
)
)
_colors
.
forEach
(
c
=>
colors
.
push
(
c
)
)
}
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barY
(
data
,
{
x
:
"primary_fur_color"
,
y
:
"foraging"
,
sort
:
{
x
:
"y"
,
reverse
:
true
}
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
voronoi
=
Plot
.
plot
(
{
marks
:
[
Plot
.
voronoi
(
data
,
{
x
:
"x"
,
y
:
"y"
,
fill
:
(
d
)
=>
{
switch
(
d
.
primary_fur_color
)
{
case
"Gray"
:
{
return
"#9aa0a3"
;
}
case
"Cinnamon"
:
{
return
"#D2691E"
;
}
case
"Black"
:
{
return
"black"
;
}
default
:
{
return
"blue"
;
}
}
}
,
stroke
:
"white"
,
title
:
"color"
,
fillOpacity
:
.75
}
)
,
Plot
.
dot
(
data
,
{
x
:
"x"
,
y
:
"y"
,
fill
:
"black"
,
pointerEvents
:
"none"
,
r
:
1
}
)
]
}
)
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
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
db
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
db
File attachments
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
colors
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
voronoi
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML