Platform
Resources
Pricing
Sign in
Get started
Matthew Berger
Workspace
Fork
Published unlisted
By
Matthew Berger
Edited
Sep 4, 2020
Insert cell
Insert cell
Insert cell
bar_data
=
d3
.
range
(
7
)
.
map
(
d
=>
200
*
Math
.
random
(
)
)
Insert cell
Insert cell
bar_svg
=
{
bar_data
// place this cell on the dependency path
return
d3
.
create
(
'svg'
)
.
attr
(
'width'
,
800
)
.
attr
(
'height'
,
300
)
// full canvas: 800 x 300
}
Insert cell
Insert cell
bar_g
=
bar_svg
.
append
(
'g'
)
.
attr
(
'transform'
,
'translate(50,50)'
)
Insert cell
Insert cell
bar_g
.
append
(
'rect'
)
.
attr
(
'width'
,
700
)
.
attr
(
'height'
,
200
)
.
attr
(
'fill'
,
d3
.
hcl
(
0
,
0
,
95
)
)
Insert cell
Insert cell
bar_dj
=
bar_g
.
selectAll
(
'g'
)
.
data
(
bar_data
)
Insert cell
drawjoin
(
bar_dj
)
Insert cell
Insert cell
bar_rect
=
bar_dj
.
enter
(
)
.
append
(
'rect'
)
Insert cell
Insert cell
bar_rect
.
attr
(
'class'
,
'bar'
)
Insert cell
Insert cell
bar_rect
.
attr
(
'x'
,
(
d
,
i
)
=>
70
*
i
)
.
attr
(
'y'
,
d
=>
200
-
d
)
.
attr
(
'height'
,
d
=>
d
)
.
attr
(
'width'
,
60
)
.
attr
(
'fill'
,
d3
.
hcl
(
0
,
0
,
50
)
)
Insert cell
Insert cell
bar_svg
.
node
(
)
Insert cell
Insert cell
Insert cell
Insert cell
grouped_bar_data
=
d3
.
range
(
3
)
.
map
(
(
_
,
i
)
=>
{
return
d3
.
range
(
4
)
.
map
(
d
=>
200
*
Math
.
random
(
)
)
}
)
Insert cell
Insert cell
grouped_bar_svg
=
{
// place this cell on the dependency path
grouped_bar_data
return
d3
.
create
(
'svg'
)
.
attr
(
'width'
,
800
)
.
attr
(
'height'
,
300
)
}
Insert cell
Insert cell
grouped_bar_g
=
grouped_bar_svg
.
append
(
'g'
)
.
attr
(
'transform'
,
'translate(50,50)'
)
Insert cell
Insert cell
grouped_bar_g
.
append
(
'rect'
)
.
attr
(
'width'
,
700
)
.
attr
(
'height'
,
200
)
.
attr
(
'fill'
,
d3
.
hcl
(
0
,
0
,
95
)
)
Insert cell
Insert cell
grouped_bar_dj
=
grouped_bar_g
.
selectAll
(
'g'
)
.
data
(
grouped_bar_data
)
Insert cell
Insert cell
grouped_bar_plots
=
grouped_bar_dj
.
enter
(
)
.
append
(
'g'
)
Insert cell
Insert cell
grouped_bar_plots
.
attr
(
'transform'
,
(
d
,
i
)
=>
`translate(${
200
*
i
},0)`
)
Insert cell
Insert cell
grouped_rect_dj
=
grouped_bar_plots
.
selectAll
(
'g'
)
.
data
(
d
=>
d
)
Insert cell
drawjoin
(
grouped_rect_dj
)
Insert cell
Insert cell
grouped_rects
=
grouped_rect_dj
.
enter
(
)
.
append
(
'rect'
)
Insert cell
Insert cell
grouped_rects
.
attr
(
'x'
,
(
d
,
i
)
=>
40
*
i
)
.
attr
(
'width'
,
35
)
.
attr
(
'height'
,
d
=>
d
)
.
attr
(
'y'
,
d
=>
200
-
d
)
.
attr
(
'fill'
,
d3
.
hcl
(
0
,
0
,
50
)
)
Insert cell
Insert cell
grouped_bar_svg
.
node
(
)
Insert cell
Insert cell
Insert cell
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
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
bar_data
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
bar_svg
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
bar_g
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
bar_dj
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
bar_rect
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
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
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
grouped_bar_data
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
grouped_bar_svg
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
grouped_bar_g
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
grouped_bar_dj
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
grouped_bar_plots
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
grouped_rect_dj
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
grouped_rects
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
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
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