Platform
Resources
Pricing
Sign in
Get started
Max Lee
MA Journalism Student at Stanford
Workspace
Fork
Published
Visualization a Week
By
Max Lee
Edited
Nov 29, 2020
1
Insert cell
Insert cell
Insert cell
Insert cell
songData
=
d3
.
csvParse
(
await
FileAttachment
(
"avg_registers.csv"
)
.
text
(
)
)
Insert cell
minRegister
=
Math
.
min
(
...
songData
.
map
(
d
=>
parseFloat
(
d
.
avg_register
)
)
)
Insert cell
yDomain
=
[
7.5
,
5
]
Insert cell
minYear
=
Math
.
min
(
...
songData
.
map
(
d
=>
parseInt
(
d
.
year
)
)
)
Insert cell
maxYear
=
Math
.
max
(
...
songData
.
map
(
d
=>
parseInt
(
d
.
year
)
)
)
Insert cell
xDomain
=
[
minYear
,
maxYear
]
Insert cell
config
=
{
return
{
padLeft
:
50
,
width
:
width
,
height
:
300
,
padTop
:
10
,
padBottom
:
50
,
padRight
:
10
,
audioRoot
:
50
,
rectWidth
:
13
,
rectHeight
:
4
}
}
Insert cell
xScale
=
d3
.
scaleLinear
(
)
.
domain
(
xDomain
)
.
range
(
[
config
.
padLeft
,
config
.
width
-
config
.
padRight
-
config
.
rectWidth
]
)
Insert cell
yScale
=
d3
.
scaleLinear
(
)
.
domain
(
yDomain
)
.
range
(
[
config
.
padTop
,
config
.
height
-
config
.
padBottom
]
)
Insert cell
xAxis
=
d3
.
axisBottom
(
xScale
)
.
tickFormat
(
d3
.
format
(
"d"
)
)
Insert cell
yAxis
=
d3
.
axisLeft
(
yScale
)
Insert cell
md
`## Imports, etc`
Insert cell
d3
=
require
(
"d3@6"
)
Insert cell
html
`
<style>
#chart-container {
position: relative;
height: ${
config
.
height
}px;
}
#chart-container svg, #chart-container canvas {
position: absolute;
}
</style>
`
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
chart
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
songData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
minRegister
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yDomain
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
minYear
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxYear
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xDomain
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
config
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML