Platform
Resources
Pricing
Sign in
Get started
Bright
Workspace
Fork
Public
By
Bright
Edited
Mar 12, 2023
Fork of
Marks and Channels / Observable Plot
Insert cell
Insert cell
Insert cell
sales
=
[
{
units
:
10
,
fruit
:
"peach"
}
,
{
units
:
20
,
fruit
:
"pear"
}
,
{
units
:
40
,
fruit
:
"plum"
}
,
{
units
:
30
,
fruit
:
"plum"
}
]
Insert cell
Insert cell
Plot
.
dot
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
}
)
.
plot
(
)
Insert cell
Insert cell
Insert cell
Plot
.
dot
(
sales
,
{
x
:
d
=>
d
.
units
*
1000
,
y
:
d
=>
d
.
fruit
}
)
.
plot
(
)
Insert cell
Insert cell
Plot
.
dot
(
sales
,
{
x
:
d
=>
d
.
units
,
y
:
d
=>
d
.
fruit
}
)
.
plot
(
{
x
:
{
label
:
"units →"
}
}
)
Insert cell
Insert cell
index
=
[
0
,
1
,
2
,
3
]
// any array of suitable length
Insert cell
units
=
[
10
,
20
,
40
,
30
]
// x₁, x₂, …
Insert cell
fruits
=
[
"peach"
,
"pear"
,
"plum"
,
"plum"
]
// y₁, y₂, …
Insert cell
Plot
.
dot
(
index
,
{
x
:
units
,
y
:
fruits
}
)
.
plot
(
)
Insert cell
Insert cell
xy
=
[
[
10
,
"peach"
]
,
// x₁, y₁
[
20
,
"pear"
]
,
// x₂, y₂
[
40
,
"plum"
]
,
// etc.
[
30
,
"plum"
]
]
Insert cell
Plot
.
dot
(
xy
)
.
plot
(
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
[
[
10
,
"peach"
]
]
)
,
// x₁, y₁
Plot
.
dot
(
[
[
20
,
"pear"
]
]
)
,
// x₂, y₂
Plot
.
dot
(
[
[
40
,
"plum"
]
]
)
,
// etc.
Plot
.
dot
(
[
[
30
,
"plum"
]
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
}
)
,
Plot
.
ruleX
(
[
0
]
)
// a rule at x = 0
]
}
)
Insert cell
Insert cell
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
}
)
.
plot
(
)
// bars extends from x = 0
Insert cell
Insert cell
Insert cell
Plot
.
barX
(
sales
,
{
x1
:
0
,
x2
:
"units"
,
y
:
"fruit"
}
)
.
plot
(
)
Insert cell
Insert cell
Plot
.
barX
(
sales
,
{
x1
:
0
,
x2
:
"units"
,
y
:
"fruit"
,
fillOpacity
:
0.5
}
)
.
plot
(
)
Insert cell
Insert cell
Plot
.
barX
(
sales
,
Plot
.
groupY
(
{
x
:
"sum"
}
,
{
x
:
"units"
,
y
:
"fruit"
}
)
)
.
plot
(
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
,
fill
:
"steelblue"
}
)
,
Plot
.
ruleX
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
,
fill
:
"fruit"
}
)
,
Plot
.
ruleX
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
,
fill
:
d
=>
d
.
fruit
}
)
,
Plot
.
ruleX
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
,
fill
:
d
=>
d
.
units
>
20
?
"black"
:
"red"
}
)
,
Plot
.
ruleX
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
color
:
{
domain
:
[
"small"
,
"big"
]
,
range
:
[
"red"
,
"black"
]
,
legend
:
true
}
,
marks
:
[
Plot
.
barX
(
sales
,
{
x
:
"units"
,
y
:
"fruit"
,
fill
:
d
=>
d
.
units
>
20
?
"big"
:
"small"
}
)
,
Plot
.
ruleX
(
[
0
]
)
]
}
)
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
sales
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
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
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
index
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
units
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
fruits
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xy
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
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
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
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
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
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
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML