Platform
Resources
Pricing
Sign in
Get started
Angie Hjort
Data graphics developer at Gapminder. Teacher at DIS Stockholm. Escaping flatland one chart at a time.
Workspace
Fork
Public
By
Angie Hjort
Edited
Jun 15, 2023
Fork of
Lesson 2: Data
5
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
unemploymentWide
=
unemploymentBLS
.
sheet
(
0
,
{
headers
:
true
}
)
Insert cell
unemploymentWide
Filter
Columns
13
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
unemploymentTall
=
aq
.
from
(
unemploymentWide
)
// create an arquero table from our data
.
fold
(
aq
.
not
(
'Year'
)
,
{
as
:
[
'Month'
,
'Unemployment'
]
}
)
// unpivot/fold the data by year, create columns Month and Unemployment
.
objects
(
)
// turn it back into a JavaScript array of objects
Insert cell
Insert cell
unemploymentTall
Filter
1
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
Insert cell
lineData
=
unemploymentTall
.
map
(
row
=>
(
{
Date
:
d3
.
utcParse
(
"%Y %b"
)
(
row
.
Year
+
" "
+
row
.
Month
)
,
//parse year and month into a proper date object
Unemployment
:
row
.
Unemployment
//copy the unemployment column without change
}
)
)
Insert cell
maximum
=
lineData
.
filter
(
f
=>
f
.
Unemployment
==
d3
.
max
(
lineData
,
d
=>
d
.
Unemployment
)
)
.
pop
(
)
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
lineY
(
lineData
,
{
x
:
"Date"
,
y
:
"Unemployment"
}
)
,
Plot
.
tip
(
[
maximum
.
Unemployment
+
"% on "
+
d3
.
utcFormat
(
"%Y %b"
)
(
maximum
.
Date
)
]
,
{
x
:
maximum
.
Date
,
y
:
maximum
.
Unemployment
,
anchor
:
"left"
}
)
]
}
)
Insert cell
Insert cell
data
Filter
1
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
data
Filter
2
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
unemploymentBLS
=
FileAttachment
(
"SeriesReport-20230614144010_3ed09f-cropped.xlsx"
)
.
xlsx
(
{
}
)
Insert cell
data
=
cars
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
unemploymentWide
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
unemploymentWide
File attachments
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
unemploymentTall
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
unemploymentTall
File attachments
Databases
Filter
Unemployment
Operator
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
lineData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maximum
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
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
data
File attachments
Databases
Filter
economy (mpg)
Operator
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
data
File attachments
Databases
Filter
economy (mpg)
Operator
power (hp)
Operator
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
parcoordsSplom
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
unemploymentBLS
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