Public
Edited
Sep 13, 2023
Insert cell
Insert cell
Insert cell
<div class='wrap'>
<div class='box xy-output'><h2>x: ${xy[0]}</h2><div>
<div class='box xy-output'><h2>y: ${xy[1]}</h2><div>
<div><h3 class='xy-time'>You have: ${time} seconds</h3></div>
</div>
Insert cell
data

Insert cell
data.push(createData(loop, xy));
Insert cell
data = []
Insert cell
xy
Insert cell
function createData(loop, xy) {
const data = [];
data.push(xy);
return data;
}
Insert cell
xy = randomXY(loop);
Insert cell
function randomXY (seed) {
const x = Math.random().toFixed(2); // decimal points
const y = Math.random().toFixed(2);
return [x, y];
}
Insert cell
delayMin = 1000; // milliseconds
Insert cell
delayMax = 8000;
Insert cell
time = (loop / 1000).toFixed(2);
Insert cell
timer = () => d3.randomUniform(delayMin, delayMax)();
Insert cell
loop = {
while (true) {
const t = timer() ;
yield t;
await Promises.delay(t);
}
}
Insert cell
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Mono&display=swap" rel="stylesheet">

<style>
.wrap {
width: ${width}px;
height: 400px;
display: flex;
justify-content: center;
align-items: center; /* vertically center to the parent container */
}
.box {
font-family: 'Space Mono', monospace;
margin: 0px;
padding: 10px;
background: #29bdad;
}
.box h2 {
padding: 10px;
margin: 0px;
font-size: 72px;
font-weight: 400;
color: #5c2c45;
}
.xy-output {
font-size: 72px;
color: #6b2e63;
text-align: center;
}
h3.xy-time {
font-size: 24px;
color: #fff;
padding-top: 20px;
padding-bottom: 10px;
text-align: center;
}
</style>
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more