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

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