Platform
Resources
Pricing
Sign in
Get started
Spring 2020 Info Vis
UW iSchool Course INFO 474: focused on designing and building visualizations to better understand and communicate about pressing issues.
Workspace
Fork
Published
By
Jin Ning Huang
Edited
Apr 25, 2020
Fork of
D3 Foundations
1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
prices_reviews
=
{
const
text
=
await
FileAttachment
(
"airbnb_seattle_listings@1.csv"
)
.
text
(
)
;
return
d3
.
csvParse
(
text
,
(
{
price
,
number_of_reviews
,
neighbourhood_group
}
)
=>
(
{
x
:
+
number_of_reviews
,
y
:
+
price
,
color
:
neighbourhood_group
}
)
)
;
}
Insert cell
Insert cell
Insert cell
Insert cell
c1_x
=
d3
.
scaleLinear
(
)
.
domain
(
[
d3
.
min
(
prices_reviews
,
d
=>
+
d
.
x
)
,
d3
.
max
(
prices_reviews
,
d
=>
+
d
.
x
)
]
)
.
range
(
[
c1_margin
.
left
,
width
-
c1_margin
.
right
]
)
Insert cell
c1_y
=
d3
.
scaleLinear
(
)
.
domain
(
[
d3
.
min
(
prices_reviews
,
d
=>
+
d
.
y
)
,
d3
.
max
(
prices_reviews
,
d
=>
+
d
.
y
)
]
)
.
range
(
[
c1_height
-
c1_margin
.
bottom
,
c1_margin
.
top
]
)
Insert cell
set_colors
=
_
.
uniqBy
(
prices_reviews
.
map
(
d
=>
d
.
color
)
)
Insert cell
Insert cell
c1_xAxis
=
g
=>
g
.
attr
(
"transform"
,
`translate(0,${
c1_height
-
c1_margin
.
bottom
})`
)
.
call
(
d3
.
axisBottom
(
c1_x
)
)
Insert cell
c1_yAxis
=
g
=>
g
.
attr
(
"transform"
,
`translate(${
c1_margin
.
left
},0)`
)
.
call
(
d3
.
axisLeft
(
c1_y
)
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart1
Insert cell
Insert cell
Insert cell
price_per_neig
=
{
const
text
=
await
FileAttachment
(
"airbnb_seattle_listings@1.csv"
)
.
text
(
)
;
return
d3
.
csvParse
(
text
,
(
{
price
,
neighbourhood_group
}
)
=>
(
{
x
:
neighbourhood_group
,
y
:
+
price
,
color
:
'lightsalmon'
}
)
)
;
}
Insert cell
//aggregate the data
group_price_per_neig
=
d3
.
nest
(
)
.
key
(
d
=>
d
.
x
)
.
rollup
(
v
=>
d3
.
mean
(
v
,
d
=>
d
.
y
)
)
.
entries
(
price_per_neig
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
neigborhood
=
_
.
unionBy
(
group_price_per_neig
,
'key'
)
.
map
(
d
=>
d
.
key
)
Insert cell
c2_x
=
d3
.
scaleLinear
(
)
.
domain
(
[
0
,
d3
.
max
(
group_price_per_neig
,
d
=>
d
.
value
)
]
)
.
range
(
[
c2_margin
.
left
,
width
-
c2_margin
.
right
]
)
Insert cell
c2_y
=
d3
.
scaleBand
(
)
.
domain
(
d3
.
range
(
group_price_per_neig
.
length
)
)
.
rangeRound
(
[
c2_margin
.
top
,
c2_height
-
c2_margin
.
bottom
]
)
.
padding
(
0.1
)
Insert cell
Insert cell
c2_xAxis_t
=
g
=>
g
.
attr
(
"transform"
,
`translate(0,${
c2_margin
.
top
})`
)
.
call
(
d3
.
axisTop
(
c2_x
)
.
ticks
(
width
/
80
,
group_price_per_neig
.
format
)
)
.
call
(
g
=>
g
.
select
(
".domain"
)
.
remove
(
)
)
Insert cell
c2_xAxis
=
g
=>
g
.
attr
(
"transform"
,
`translate(0,${
c2_height
-
c2_margin
.
bottom
-
11.6
})`
)
.
call
(
d3
.
axisBottom
(
c2_x
)
)
Insert cell
c2_yAxis
=
g
=>
g
.
attr
(
"transform"
,
`translate(${
c2_margin
.
left
},0)`
)
.
call
(
d3
.
axisLeft
(
c2_y
)
.
tickFormat
(
i
=>
group_price_per_neig
[
i
]
.
key
)
.
tickSizeOuter
(
0
)
)
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
color_scale
=
d3
.
scaleOrdinal
(
set_colors
,
d3
.
schemeCategory10
)
Insert cell
format
=
c2_x
.
tickFormat
(
20
,
group_price_per_neig
.
format
)
Insert cell
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
reading
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
loading_data
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
scales
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
axes
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
marks
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
charts
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
prices_reviews
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
c1_margin
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c1_height
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c1_x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c1_y
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set_colors
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
c1_xAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c1_yAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c1_legend
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
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
chart1
Edit
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
price_per_neig
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
group_price_per_neig
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
c2_margin
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_height
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
barHeight
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
neigborhood
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_y
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
c2_xAxis_t
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_xAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_yAxis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
c2_legend
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
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
c2_chart
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
appendix
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
_
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
color_scale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
format
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