Platform
Resources
Pricing
Sign in
Get started
Darya Yarparvar
I’m a graphic designer and data visualiser. Colours, patterns, and data get my pulse racing!
Workspace
Fork
Public
By
Darya Yarparvar
Edited
Apr 25, 2023
1 fork
17
Insert cell
Insert cell
years
=
Array
.
from
(
{
length
:
17
}
,
(
d
,
i
)
=>
2006
+
i
)
Insert cell
yearsKey
=
years
.
map
(
y
=>
`year_${
y
}`
)
Insert cell
data
=
new
Object
// you have to define data as an object first
Insert cell
yearsKey
.
map
(
k
=>
data
[
k
]
=
[
]
)
// you have to define data.year as an array first
Insert cell
Insert cell
fragileStatesIndex0
=
await
FileAttachment
(
"2006-fragile states index.xlsx"
)
.
xlsx
(
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
raw_data
=
[
year_2006
,
year_2007
,
year_2008
,
year_2009
,
year_2010
,
year_2011
,
year_2012
,
year_2013
,
year_2014
,
year_2015
,
year_2016
,
year_2017
,
year_2018
,
year_2019
,
year_2020
,
year_2021
,
year_2022
]
Insert cell
raw_data
.
map
(
(
yearData
,
y
)
=>
yearData
.
slice
(
1
)
.
map
(
(
d
,
i
)
=>
data
[
yearsKey
[
y
]
]
[
i
]
=
new
Object
)
)
Insert cell
raw_data
.
map
(
(
yearData
,
y
)
=>
yearData
.
slice
(
1
)
.
map
(
(
d
,
i
)
=>
Object
.
keys
(
d
)
.
map
(
(
key
,
j
)
=>
data
[
yearsKey
[
y
]
]
[
i
]
[
keys
[
j
]
]
=
d
[
key
]
)
)
)
Insert cell
data
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data
Insert cell
Insert cell
Insert cell
tables_aq
=
new
Object
Insert cell
yearsKey
.
map
(
y
=>
tables_aq
[
y
]
=
aq
.
from
(
data
[
y
]
)
)
// generate aquero table data for each year and hold it together in tables_aq
Insert cell
tables_aq
// aquero table data for all years
Insert cell
viewof
yearInput
=
Inputs
.
select
(
years
,
{
label
:
"Select the year"
}
)
Insert cell
tables_aq
[
`year_${
yearInput
}`
]
.
view
(
)
// visualise the selected year's tabular data with aquero .view()
Insert cell
Insert cell
table_plot_input
=
data
[
`year_${
yearInput
}`
]
// for using Plot table you should have year_data as a separate database ready first.
Insert cell
table_plot_input
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
data_aq
=
new
Object
Insert cell
yearsKey
.
map
(
year
=>
data_aq
[
year
]
=
tables_aq
[
year
]
.
objects
(
)
)
// access the wrangled data by aquero via .objects()
Insert cell
data_aq
// whatever wrangling you do with aquero will be reflected in this dataset. use this for d3 usage.
Insert cell
tables_aq
[
`year_${
yearInput
}`
]
.
derive
(
{
Rank
:
d
=>
d
.
Rank
.
match
(
"/\d+/"
)
}
)
.
view
(
)
Insert cell
Insert cell
Insert cell
addTooltips
(
// draw plot with tooltip
Plot
.
plot
(
{
//layout
marginLeft
:
80
,
marginRight
:
80
,
marginTop
:
30
,
marginBottom
:
80
,
inset
:
80
,
width
:
600
,
height
:
600
,
//Visual Encoding (specifying which visual channels you are using and relating each visual channel to a property)
//mark configuration
marks
:
[
Plot
.
dot
(
data
.
year_2006
,
{
x
:
"Economy"
,
y
:
"Human Rights"
,
sort
:
{
x
:
"y"
}
,
stroke
:
"Total"
,
fill
:
"none"
,
r
:
3
,
title
:
(
d
)
=>
`${
d
.
Country
} \n rank: ${
d
.
Rank
}`
}
)
// \n makes a new line
]
,
//scale configurations & their label, tick, legend, ...
x
:
{
type
:
"linear"
,
domain
:
[
0
,
10
]
,
ticks
:
10
,
tickFormat
:
",.1s"
,
//symbol comma precision type
label
:
"Economy"
,
labelAnchor
:
"right"
,
labelOffset
:
5
,
nice
:
true
,
tickPadding
:
20
,
tickRotate
:
0
,
//tickSize: 25,
axis
:
"bottom"
,
inset
:
20
,
line
:
true
,
//percent: true,
//reverse: true,
//grid: true,
legend
:
true
,
}
,
y
:
{
type
:
"linear"
,
domain
:
[
0
,
10
]
,
ticks
:
10
,
tickFormat
:
",.1s"
,
//symbol comma precision type
label
:
"Human Rights"
,
labelAnchor
:
"top"
,
labelOffset
:
25
,
nice
:
true
,
tickPadding
:
20
,
tickRotate
:
0
,
//tickSize: 25,
axis
:
"left"
,
inset
:
20
,
line
:
true
,
//percent: true,
//reverse: true,
//grid: true,
legend
:
true
,
}
,
color
:
{
type
:
"linear"
,
scheme
:
"pubugn"
,
legend
:
true
,
reverse
:
true
}
,
// //caption
caption
:
"Human Rights vs Economy [year_2006] - with tooltip"
}
)
,
// Set styles for the hovered element (related to addTooltips)
{
fill
:
"turquoise"
,
opacity
:
0.5
,
"stroke-width"
:
"3px"
,
stroke
:
"none"
,
r
:
4
}
)
Insert cell
addTooltips
(
// draw plot with tooltip
Plot
.
plot
(
{
//layout
marginLeft
:
80
,
marginRight
:
100
,
marginTop
:
30
,
marginBottom
:
80
,
inset
:
80
,
width
:
600
,
height
:
600
,
//Visual Encoding (specifying which visual channels you are using and relating each visual channel to a property)
//mark configuration
marks
:
[
Plot
.
dot
(
data
.
year_2006
,
{
x
:
"Refugees and IDPs"
,
y
:
"Economic Inequality"
,
sort
:
{
x
:
"y"
}
,
stroke
:
"Total"
,
fill
:
"none"
,
r
:
3
,
title
:
(
d
)
=>
`${
d
.
Country
} \n rank: ${
d
.
Rank
}`
}
)
// \n makes a new line
]
,
//scale configurations & their label, tick, legend, ...
x
:
{
type
:
"linear"
,
domain
:
[
0
,
10
]
,
ticks
:
10
,
tickFormat
:
",.1s"
,
//symbol comma precision type
label
:
"Refugees and IDPs"
,
labelAnchor
:
"right"
,
labelOffset
:
5
,
nice
:
true
,
tickPadding
:
20
,
tickRotate
:
0
,
//tickSize: 25,
axis
:
"bottom"
,
inset
:
20
,
line
:
true
,
//percent: true,
//reverse: true,
//grid: true,
legend
:
true
,
}
,
y
:
{
type
:
"linear"
,
domain
:
[
0
,
10
]
,
ticks
:
10
,
tickFormat
:
",.1s"
,
//symbol comma precision type
label
:
"Economic Inequality"
,
labelAnchor
:
"top"
,
labelOffset
:
50
,
nice
:
true
,
tickPadding
:
20
,
tickRotate
:
0
,
//tickSize: 25,
axis
:
"left"
,
inset
:
20
,
line
:
true
,
//percent: true,
//reverse: true,
//grid: true,
legend
:
true
,
}
,
color
:
{
type
:
"linear"
,
scheme
:
"pubugn"
,
legend
:
true
,
reverse
:
true
}
,
// //caption
caption
:
"Refugees and IDPs vs Economic Inequality [year_2006] - with tooltip"
}
)
,
// Set styles for the hovered element (related to addTooltips)
{
fill
:
"turquoise"
,
opacity
:
0.5
,
"stroke-width"
:
"3px"
,
stroke
:
"none"
,
r
:
4
}
)
Insert cell
Insert cell
import
{
aq
,
op
}
from
"@uwdata/arquero"
Insert cell
import
{
addTooltips
}
from
"@mkfreeman/plot-tooltip"
Insert cell
import
{
show
}
from
"@observablehq/plot-default-height"
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
years
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yearsKey
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex0
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex1
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex2
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex3
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex4
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex5
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex6
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex7
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex8
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex9
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex10
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex11
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex12
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex13
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex14
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex15
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fragileStatesIndex16
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
extraParts
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
extraPartsAll
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
keys
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
raw_data
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2006
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2007
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2008
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2009
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2010
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2011
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2012
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2013
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2014
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2015
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2016
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2017
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2018
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2019
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2020
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2021
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year_2022
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
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
tables_aq
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
yearInput
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
table_plot_input
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
table_per_year
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
Cells
table_plot_input
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
data_aq
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
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
Add comment
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
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML