Platform
Resources
Pricing
Sign in
Get started
Eric Field
Building and Using Tools to See. UVA Architecture + Data Science. IT Director. Instructor.
Workspace
Fork
Published
the Basics
By
Eric Field
Edited
Feb 7, 2022
1 star
the Basics
Intro to Observable, HTML, and SVG
SVG Object Types and attributes
SVG Stacked Bar Graph
Drawing Objects Procedurally
D3 baby steps
D3 element templates
the Data in D3
D3 Dynamics baby steps
D3 join, with updating data
Insert cell
Insert cell
Insert cell
Insert cell
<
div
id
=
"mosaic"
>
</
div
>
Insert cell
count
=
200
// change this number and hit Run Cell >
Insert cell
<
style
>
#
mosaic
{
line-height
:
0
}
#
mosaic
div
{
width
:
20
px
;
height
:
20
px
;
display
:
inline-block
;
}
</
style
>
Insert cell
randColor
=
(
)
=>
{
let
r
=
Math
.
random
(
)
*
255
;
let
g
=
Math
.
random
(
)
*
255
;
let
b
=
Math
.
random
(
)
*
255
;
return
"rgb("
+
r
+
","
+
g
+
","
+
b
+
")"
;
}
Insert cell
boxes
=
d3
.
select
(
mosaic
)
.
selectAll
(
"div"
)
.
data
(
d3
.
range
(
count
)
)
.
join
(
"div"
)
.
style
(
"background-color"
,
randColor
)
Insert cell
Insert cell
Insert cell
Insert cell
<
svg
id
=
"randcircles"
width
=
"400"
height
=
"400"
>
</
svg
>
Insert cell
randLocation
=
(
)
=>
Math
.
random
(
)
*
400
Insert cell
circles
=
d3
.
select
(
randcircles
)
.
selectAll
(
"circle"
)
.
data
(
d3
.
range
(
count
)
)
.
join
(
"circle"
)
.
attr
(
"cx"
,
randLocation
)
.
attr
(
"cy"
,
randLocation
)
.
attr
(
"r"
,
12
)
.
style
(
"fill"
,
"yellow"
)
.
style
(
"stroke"
,
"black"
)
.
style
(
"opacity"
,
0.7
)
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mosaic
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
count
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randColor
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
boxes
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
randcircles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randLocation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
circles
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