Platform
Resources
Pricing
Sign in
Get started
Shachee Swadia
Data Designer and Content Creator
Workspace
Fork
Public
By
Shachee Swadia
Edited
Jul 7, 2023
2
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
lineY
(
aapl
,
{
x
:
"Date"
,
y
:
"Close"
}
)
]
}
)
Insert cell
workbook
=
FileAttachment
(
"UK Divorces.xlsx"
)
.
xlsx
(
)
Insert cell
sheet1
=
workbook
.
sheet
(
"By Decree"
)
Insert cell
Inputs
.
table
(
sheet1
)
Insert cell
file
=
FileAttachment
(
"UKDivorces@1.csv"
)
Insert cell
data
=
d3
.
csvParse
(
await
file
.
text
(
)
)
Insert cell
filteredData
=
data
.
filter
(
d
=>
d
.
Year
>=
1974
)
Insert cell
finalData
=
filteredData
.
map
(
d
=>
{
d
[
'Male'
]
=
+
d
[
'Male'
]
.
replace
(
/,/g
,
''
)
;
d
[
'Female'
]
=
+
d
[
'Female'
]
.
replace
(
/,/g
,
''
)
;
d
[
'Total'
]
=
+
d
[
'Total'
]
.
replace
(
/,/g
,
''
)
;
return
d
}
)
Insert cell
dataToUse
=
filteredData
.
map
(
d
=>
{
d
[
'MalePoT'
]
=
d
[
'Male'
]
/
d
[
'Total'
]
;
d
[
'FemalePoT'
]
=
d
[
'Female'
]
/
d
[
'Total'
]
;
return
d
}
)
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
lineY
(
filteredData
,
{
x
:
"Year"
,
y
:
"Total"
}
)
]
}
)
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
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
workbook
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sheet1
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
file
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
filteredData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
finalData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataToUse
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML