From 73d75835e18a33c7f6c1b09bbcef93b16a7a9bfa Mon Sep 17 00:00:00 2001 From: Thomas Grothe Date: Thu, 30 Apr 2026 00:53:13 -0400 Subject: redo timeplot web --- web-timeplot/src/plot/plot-buffer.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 web-timeplot/src/plot/plot-buffer.js (limited to 'web-timeplot/src/plot/plot-buffer.js') diff --git a/web-timeplot/src/plot/plot-buffer.js b/web-timeplot/src/plot/plot-buffer.js new file mode 100644 index 0000000..b13cdd8 --- /dev/null +++ b/web-timeplot/src/plot/plot-buffer.js @@ -0,0 +1,22 @@ +export class PlotBuffer { + constructor(maxPoints = 1600) { + this.maxPoints = maxPoints; + this.points = []; + } + + addPoint(point) { + this.points.push(point); + if (this.points.length > this.maxPoints) { + this.points.splice(0, this.points.length - this.maxPoints); + } + } + + clear() { + this.points = []; + } + + getVisiblePoints(currentPlotTimeMs, windowDurationMs) { + const minTime = currentPlotTimeMs - windowDurationMs; + return this.points.filter((point) => point.timeMs >= minTime && point.timeMs <= currentPlotTimeMs); + } +} -- cgit v1.2.3