Published
Edited
Sep 25, 2021
3 forks
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sineWave = { // generate a sine wave array of [x, y] coordinates
const waveForm = (td, len) => d3.range(len).map( n => {
const TAU = Math.PI * 2
const x = (n * seconds) / (len - 1)
const timeStamp = (td / 1000 - x)
const y = Math.sin(timeStamp * TAU * frequency)
return [x, y]
})
const t0 = Date.now() // init time of generator
while (true) {
const timeDelta = Date.now() - t0 // ms since generator started
yield Promises.delay(5, waveForm(timeDelta, streamLength)) // generate value every 5 ms
}
}

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