Platform
Resources
Pricing
Sign in
Get started
Camille Lust
Workspace
Fork
Public
By
Camille Lust
Edited
Feb 4, 2023
Fork of
My first exercise
3
Insert cell
md
`# My First Exercise on Observable`
Insert cell
d3
=
require
(
"d3@5"
)
Insert cell
topojson
=
require
(
"topojson-client@3"
)
Insert cell
states48
=
FileAttachment
(
"states48.json"
)
.
json
(
)
Insert cell
states_features
=
topojson
.
feature
(
states
.
objects
.
states48
)
Insert cell
csv_data
=
d3
.
csvParse
(
await
FileAttachment
(
"iowa_counties.csv"
)
.
text
(
)
,
(
{
FIPS
,
FEMALES
,
POP2010
}
)
=>
[
FIPS
,
[
+
FEMALES
,
+
FEMALES
/
+
POP2010
]
]
)
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
femalepct
=
Array
.
from
(
csv_data
.
values
(
)
,
d
=>
d
[
1
]
[
1
]
)
Insert cell
//this is how you map the id column to the values. We will use this for joining with topojson later.
data
=
Object
.
assign
(
new
Map
(
csv_data
)
,
{
title
:
[
"Females"
,
"Female Pct"
]
}
)
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
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
states48
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
femalepct
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