Notebooks 2.0 is here.
Read the preview announcement
Platform
Resources
Pricing
Sign in
Get started
RyanWu
微信公众号:优雅的算法
Workspace
Fork
Published
By
RyanWu
Edited
Aug 5, 2019
Fork of
Demo
Insert cell
Insert cell
Insert cell
1
+
1
// Edit me!
Insert cell
Insert cell
{
let
sum
=
0
;
for
(
let
i
=
0
;
i
<
100
;
++
i
)
{
sum
+=
i
;
}
return
sum
;
}
Insert cell
Insert cell
color
=
"red"
// Edit me!
Insert cell
`My favorite color is ${
color
}.`
Insert cell
Insert cell
object
=
(
{
open
:
[
atob
(
"c2VzYW1l"
)
]
}
)
Insert cell
Insert cell
html
`<span style="background:yellow;">
My favorite language is <i>HTML</i>.
</span>`
Insert cell
md
`Hi Mom! It’s me, *Markdown*.`
Insert cell
Insert cell
html
`My favorite color is <i style="background:${
color
};">${
color
}</i>.`
Insert cell
Insert cell
cars
=
fetch
(
"https://raw.githubusercontent.com/vega/vega/v4.3.0/docs/data/cars.json"
)
.
then
(
response
=>
response
.
json
(
)
)
Insert cell
Insert cell
d3
=
require
(
"d3-array@2"
)
Insert cell
Insert cell
d3
.
median
(
cars
,
d
=>
d
.
Horsepower
)
Insert cell
Insert cell
function
greet
(
subject
)
{
return
`Hello, ${
subject
}!`
;
}
Insert cell
greet
(
"world"
)
Insert cell
Insert cell
c
=
{
for
(
let
i
=
0
;
true
;
++
i
)
{
yield
i
;
}
}
Insert cell
Insert cell
Insert cell
{
const
height
=
33
;
const
context
=
DOM
.
context2d
(
width
,
height
)
;
for
(
let
i
=
0
;
i
<
width
;
++
i
)
{
const
t
=
i
/
width
;
const
r
=
Math
.
floor
(
255
*
Math
.
sin
(
Math
.
PI
*
(
t
+
0
/
3
)
)
**
2
)
;
const
g
=
Math
.
floor
(
255
*
Math
.
sin
(
Math
.
PI
*
(
t
+
1
/
3
)
)
**
2
)
;
const
b
=
Math
.
floor
(
255
*
Math
.
sin
(
Math
.
PI
*
(
t
+
2
/
3
)
)
**
2
)
;
context
.
fillStyle
=
`rgb(${
r
},${
g
},${
b
})`
;
context
.
fillRect
(
i
,
0
,
1
,
height
)
;
yield
context
.
canvas
;
}
}
Insert cell
Insert cell
tick
=
{
while
(
true
)
{
const
date
=
new
Date
(
Math
.
ceil
(
Date
.
now
(
)
/
1000
)
*
1000
)
;
await
Promises
.
when
(
date
)
;
yield
date
;
}
}
Insert cell
Insert cell
slider
=
html
`<input type=range>`
Insert cell
sliderValue
=
Generators
.
input
(
slider
)
Insert cell
Insert cell
viewof
d
=
html
`<input type=range>`
// Edit me! Try type=text.
Insert cell
Insert cell
Insert cell
import
{
tweet
}
from
"@mbostock/tweet"
Insert cell
tweet
(
"958726175123128321"
)
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
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
color
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
object
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
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
cars
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
d3
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
greet
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
c
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tick
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
slider
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sliderValue
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
d
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
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML