Published
Edited
Sep 6, 2021
Importers
Insert cell
Insert cell
function* genValue(
start, // an initial value
minV = 0, // minimum value
maxV = 1.0, // maximum value
cent = 0.2, // percentage of value range to vary
frequency = 1 // oscillation frequency
) {
const range = (maxV - minV) * cent;
const hrange = range / 2;
const getNextSin = (v, i) =>
start + hrange + hrange * Math.sin(i * 0.065 * frequency);
let nextV = start;
let i = 0;
while (true) {
nextV = getNextSin(nextV, i++);
yield nextV;
}
}
Insert cell
Insert cell
data0 = {
const gv = genValue(30, 0, 100);
const buf = [];
for (let i = 0; i < 1000; i++) {
buf.push(gv.next().value);
}
return buf;
}
Insert cell
Insert cell
data = {
const gv = genValue(24, 0, 360, 0.3, 2);
const buf = [];
for (let i = 0; i < 1000; i++) {
buf.push(gv.next().value);
}
return buf;
}
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