p5((sketch) => {
sketch.setup = function () {
const cnv = sketch.createCanvas(width, 300);
cnv.id('canvas');
const canvas = document.getElementById('canvas');
const canv = canvas.getContext("2d");
sketch.stroke(30, 80, 255);
sketch.strokeWeight(2);
let data = d3.range(9).map((i) => Math.random() * 10);
let fx = (_) => sketch.map(_, 0, 9, 0, width);
let fy = (_) => sketch.map(_, 0, 10, 100, 300);
let line = d3
.line()
.x((d, i) => fx(i))
.y((d) => fy(d))
.curve(d3.curveBasis);
let path = new Path2D(line(data));
canvas.getContext("2d").stroke(path);
canv.stroke(p);
sketch.noLoop();
};
sketch.draw = function () {
};
})