Platform
Resources
Pricing
Sign in
Get started
cfienup
Workspace
Fork
Published
By
cfienup
Edited
Mar 4, 2020
2
Insert cell
md
`# Assignment One`
Insert cell
d3
=
require
(
"d3@5"
)
Insert cell
topojson
=
require
(
"topojson-client@3"
)
Insert cell
nycounties
=
FileAttachment
(
"NYCountiesWGS1984.json"
)
.
json
(
)
Insert cell
states_features
=
topojson
.
feature
(
nycounties
,
nycounties
.
objects
.
NYCountiesWGS1984
)
Insert cell
csv_data
=
d3
.
csvParse
(
await
FileAttachment
(
"NYPOP@1.csv"
)
.
text
(
)
,
(
{
FIPS
,
Population
,
Area
}
)
=>
[
FIPS
,
[
+
Population
,
+
Population
/
+
Area
]
]
)
Insert cell
popdensity
=
Array
.
from
(
csv_data
.
values
(
)
,
d
=>
d
[
1
]
[
1
]
)
Insert cell
linear
=
d3
.
scaleLinear
(
)
.
domain
(
[
0
,
d3
.
max
(
popdensity
)
]
)
.
range
(
[
"white"
,
"red"
]
)
Insert cell
quantize
=
d3
.
scaleQuantize
(
)
.
domain
(
d3
.
extent
(
popdensity
)
)
.
range
(
[
"white"
,
"pink"
,
"red"
]
)
Insert cell
quantile
=
d3
.
scaleQuantile
(
)
.
domain
(
popdensity
)
.
range
(
[
"white"
,
"pink"
,
"red"
]
)
Insert cell
naturalbreaks3
=
simple
.
ckmeans
(
popdensity
,
5
)
.
map
(
v
=>
v
.
pop
(
)
)
Insert cell
threshldNB3
=
d3
.
scaleThreshold
(
)
.
domain
(
naturalbreaks3
)
.
range
(
[
"white"
,
"pink"
,
"red"
]
)
Insert cell
//map the id column to the values. Use this for joinging with topojson later
data
=
Object
.
assign
(
new
Map
(
csv_data
)
,
{
title
:
[
"Population"
,
"PopulationDensity"
]
}
)
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
topojson
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
nycounties
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
states_features
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
csv_data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
popdensity
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
linear
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
quantize
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
quantile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
naturalbreaks3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
threshldNB3
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