Published
Edited
Feb 16, 2022
2 stars
Insert cell
Insert cell
Insert cell
function oscillate(from, to, duration) {
return x => from + (to - from) * (0.5 - 0.5 * Math.cos((2 * Math.PI / duration) * x))
}
Insert cell
Insert cell
i = oscillate(0, 1, 1000)
Insert cell
i(now)
Insert cell
Plot.line(d3.range(0, 1e4, 10), {x: d => d, y: d => i(d)}).plot({width})
Insert cell
Insert cell
oscillate2 = (n) => -Math.abs(2 * (n % 1) - 1) + 1;
Insert cell
Plot.line(d3.range(0, 3.1, 0.1), {x: d => d, y: d => oscillate2(d)}).plot({width})
Insert cell
Insert cell
scale = d3.scaleLinear([0, 0.1, 0.5, 0.6, 1], [0, 1, 1, 0, 0])
Insert cell
Plot.line(d3.range(0, 2, 0.01), {x: d => d, y: d => scale(d % 1)}).plot()
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