Public
Edited
Jan 4, 2023
6 forks
Importers
57 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
length = 100 // try changing this number and running the cell with shift-enter
Insert cell
height = 60 // or change this one, a cell can depend on lots of other cells
Insert cell
html`<div style="width: ${length}px; height: ${height}px; background-color: blue;"></div>`
Insert cell
`the width is ${length} and the height is ${height}` // note a cell can be referenced from multiple cells too!
Insert cell
Insert cell
Insert cell
sliderThatDoesNothing = html`<input type="range" min="0" max="${width}" value="50"></input>`
Insert cell
Insert cell
Insert cell
Insert cell
viewof greenLength = html`<input type="range" min="0" max="800" value="50"></input>`
Insert cell
Insert cell
html`<div style="width: ${greenLength}px; height: ${height}px; background-color: green;"></div>`
Insert cell
Insert cell
greenLength + " pixels wide"
Insert cell
greenLength % 2 === 0 ? "A nice even length." : "What an odd length!"
Insert cell
Insert cell
Insert cell
viewof simple = slider()
Insert cell
simple
Insert cell
viewof money = slider({
min: 0,
max: 1e9,
step: 1000,
value: 3250000,
format: ",",
description:
"Zero to one billion, in steps of one thousand, formatted as a (US) number"
})
Insert cell
money
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof range = rangeSlider({
min: 0,
max: 200,
value: [50, 150],
precision: 0, // how many decimal places
title: 'Ranges of numbers between 0 and 200',
})
Insert cell
range
Insert cell
Insert cell
Insert cell
Insert cell
viewof coordinates = worldMapCoordinates([-122.27, 37.87])
Insert cell
coordinates
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
counterGenerator = function*() {
let i = 0;
while (true) {
yield i++;
}
}
Insert cell
Insert cell
counterGenerator()
Insert cell
Insert cell
i = {
let i = 0;
while (true) {
yield i;
i+= 3;
if (i > 800) {
i = 0;
}
}
}
Insert cell
Insert cell
html`<div style="width: ${i}px; height: 60px; background-color: green;"></div>`
Insert cell
Insert cell
Insert cell
Insert cell
viewof keyframe = Scrubber(keyframes, {
format: ([date]) => formatDate(date),
delay: duration,
loop: false
})
Insert cell
Insert cell
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.
Learn more