plot = (settings) => (data) => {
const {VIN, stroke, height, backgroundColor, t, tmax, plotY = 72, gridStroke, channels} = settings;
const y = v(t / tmax);
const x = t;
const axis = ({
stroke,
textStroke: "transparent",
fill: stroke,
});
const p = Plot.plot(
{
width, height: height - plotY,
style: {
backgroundColor,
stroke,
},
axis: null,
x:{
label: "→ time (ms)",
},
y: {
nice: true,
label: "↑ voltage (V)",
},
marks: [
grid({stroke: gridStroke, tmax, axis}),
cursor(settings)({x, y}),
Plot.line(data, {x: "t", y: "u", stroke: color(channels)(0)}),
Plot.line([{x: 0, y: VIN}, {x: tmax, y: VIN}], {x: "x", y: "y", stroke: color(channels)(1)}),
]
}
);
d3.select(p).attr("y", plotY);
return p;
}