Skip to content

Commit

Permalink
feat: specify decimal places per signal
Browse files Browse the repository at this point in the history
  • Loading branch information
oneirocosm committed Oct 17, 2024
1 parent 95492f6 commit 8af3bdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/app/view/sysinfo/sysinfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function defaultCpuMeta(name: string): TimeSeriesMeta {
miny: 0,
maxy: 100,
color: "var(--sysinfo-cpu-color)",
decimalPlaces: 0,
};
}

Expand All @@ -42,6 +43,7 @@ function defaultMemMeta(name: string, maxY: string): TimeSeriesMeta {
miny: 0,
maxy: maxY,
color: "var(--sysinfo-mem-color)",
decimalPlaces: 1,
};
}

Expand Down Expand Up @@ -359,6 +361,7 @@ function SingleLinePlot({
const plotHeight = domRect?.height ?? 0;
const plotWidth = domRect?.width ?? 0;
const marks: Plot.Markish[] = [];
let decimalPlaces = yvalMeta?.decimalPlaces ?? 0;
let color = yvalMeta?.color;
if (!color) {
color = defaultColor;
Expand Down Expand Up @@ -420,7 +423,8 @@ function SingleLinePlot({
fill: "var(--main-bg-color)",
anchor: "middle",
dy: -30,
title: (d) => `${dayjs.unix(d.ts / 1000).format("M:ss")} ${Math.round(d[yval])}${labelY}`,
title: (d) =>
`${dayjs.unix(d.ts / 1000).format("M:ss")} ${Number(d[yval]).toFixed(decimalPlaces)}${labelY}`,
textPadding: 3,
})
)
Expand Down
1 change: 1 addition & 0 deletions frontend/types/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ declare global {
label?: string;
maxy?: string | number;
miny?: string | number;
decimalPlaces?: number;
};
}

Expand Down

0 comments on commit 8af3bdb

Please sign in to comment.