From 031f151f566dc1456fef865ee7862a71b6e8fe44 Mon Sep 17 00:00:00 2001 From: Alexander Kimmig Date: Tue, 3 Jun 2025 00:09:34 +0200 Subject: [PATCH] plot.ts aktualisiert --- plot.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plot.ts b/plot.ts index dd4430c..79e5e36 100644 --- a/plot.ts +++ b/plot.ts @@ -6,4 +6,10 @@ export const document = new DOMParser().parseFromString( export const plot = (data) => { return Plot.line(data, {x: "x", y: "y"}).plot({y: {grid: true}, document}) +} + +export const plotxy = (xmin, xmax, step, y) => { + const x = Array.from({length: (xmax - xmin)/step}, (_, i) => (i - xmin) * step) + const data = x.map(x => ({x, y: y(x)})) + return Plot.line(data, {x: "x", y: "y"}).plot({y: {grid: true}, document}) } \ No newline at end of file