JavaScript Tutorial
Canevas HTML

laissez xMax = canvas.height;
laissez yMax = canvas.width;
soit pente = 1,2 ;
soit intercepter = 70 ;
const xTableau = [50,60,70,80,90,100,110,120,130,140,150];
const yArray = [7,8,8,9,9,9,10,11,14,14,15];
// Dispersion du tracé
ctx.fillStyle = « rouge » ;
for (let i = 0; i < xArray.length-1; i++) {
soit x = xTableau[i]*400/150 ;
soit y = yTableau[i]*400/15 ;
ctx.beginPath();
ctx.ellipse(x, y, 2, 3, 0, 0, Math.PI * 2);
ctx.fill();
}
// Intrigue
ctx.moveTo(0, interception);
ctx.lineTo(xMax, f(xMax));
ctx.strokeStyle = « noir » ;
ctx.stroke();
// Fonction de ligne
fonction f(x) {
retour x * pente + interception ;
}
#Canevas #HTML