Public
Edited
Apr 9, 2023
Paused
Insert cell
Insert cell
function generatePoints(n, maxValue = 100) {
let points = [];
for (let i = 0; i < n; i++) {
let x = i;
let y = Math.random() * maxValue;
if (i == 0 || i == n-1) {
points.push({ x: x, y: maxValue / 2 });
} else {
points.push({ x: x, y: y });
}
}
return points;
}
Insert cell
data = generatePoints(25)
Insert cell
wave = Plot.plot({
inset: 10,
x: { axis: null },
y: { axis: null },
width,
marks: [
Plot.line(data, {
x: "x",
y: "y",
curve: "catmull-rom",
strokeWidth: 5
})
]
})
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