import * as Plot from "npm:@observablehq/plot"; import { DOMParser, SVGElement } from "npm:linkedom"; 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}) }