feature:add plot panel x,y axis
This commit is contained in:
@@ -398,10 +398,12 @@
|
||||
const safeIndex = clamp(index, 0, replayFrames.length - 1);
|
||||
const startIndex = Math.max(0, safeIndex - summaryPointsPerSeries + 1);
|
||||
const points: number[] = [];
|
||||
const frameIds: number[] = [];
|
||||
for (let cursor = startIndex; cursor <= safeIndex; cursor += 1) {
|
||||
points.push(replayFrameTotal(replayFrames[cursor]));
|
||||
frameIds.push(cursor + 1);
|
||||
}
|
||||
return buildSummary(points);
|
||||
return buildSummary(points, frameIds);
|
||||
}
|
||||
|
||||
function applyReplayFrame(index: number): void {
|
||||
@@ -573,6 +575,7 @@
|
||||
function buildEmptySummary(): HudSummary {
|
||||
return {
|
||||
label: "TOTAL",
|
||||
xValues: [],
|
||||
points: [],
|
||||
latest: null,
|
||||
min: null,
|
||||
@@ -580,13 +583,19 @@
|
||||
};
|
||||
}
|
||||
|
||||
function buildSummary(points: number[]): HudSummary {
|
||||
function buildSummary(points: number[], xValues: number[] = []): HudSummary {
|
||||
if (points.length === 0) {
|
||||
return buildEmptySummary();
|
||||
}
|
||||
|
||||
const resolvedXValues = points.map((_, index) => {
|
||||
const x = xValues[index];
|
||||
return Number.isFinite(x) ? Number(x) : index + 1;
|
||||
});
|
||||
|
||||
return {
|
||||
label: "TOTAL",
|
||||
xValues: resolvedXValues,
|
||||
points,
|
||||
latest: points[points.length - 1],
|
||||
min: Math.min(...points),
|
||||
@@ -611,13 +620,20 @@
|
||||
? summaryValue.points[summaryValue.points.length - 1]
|
||||
: randomBetween(280, 1600);
|
||||
const next = Math.round(clamp(previous + randomBetween(-160, 160), 120, 2400) * 10) / 10;
|
||||
const previousXValues =
|
||||
summaryValue.xValues && summaryValue.xValues.length === summaryValue.points.length
|
||||
? summaryValue.xValues
|
||||
: summaryValue.points.map((_, index) => index + 1);
|
||||
const points =
|
||||
summaryValue.points.length >= summaryPointsPerSeries
|
||||
? summaryValue.points.slice(1)
|
||||
: summaryValue.points.slice();
|
||||
const xValues =
|
||||
previousXValues.length >= summaryPointsPerSeries ? previousXValues.slice(1) : previousXValues.slice();
|
||||
|
||||
points.push(next);
|
||||
return buildSummary(points);
|
||||
xValues.push((xValues[xValues.length - 1] ?? 0) + 1);
|
||||
return buildSummary(points, xValues);
|
||||
}
|
||||
|
||||
function buildInactivePanels(): HudSignalPanel[] {
|
||||
|
||||
Reference in New Issue
Block a user