Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
49c5dff
1
Parent(s): 4640159
fix: allow staff cross-workspace live events via WebSockets
Browse files
frontend/apps/internal/src/components/InfraMonitor.tsx
CHANGED
|
@@ -65,16 +65,21 @@ const getAgentIcon = (name: string) => {
|
|
| 65 |
const Sparkline = ({ data, color, loading }: { data: number[], color: string, loading: boolean }) => {
|
| 66 |
if (loading || data.length === 0) return <div style={{ height: 40 }} />;
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
const range = max - min || 1;
|
| 71 |
const width = 200;
|
| 72 |
const height = 40;
|
| 73 |
|
| 74 |
-
const points =
|
| 75 |
-
const x = (i / (
|
| 76 |
const y = height - ((val - min) / range) * height;
|
| 77 |
-
|
|
|
|
| 78 |
}).join(' ');
|
| 79 |
|
| 80 |
const areaPoints = `${points} ${width},${height} 0,${height}`;
|
|
|
|
| 65 |
const Sparkline = ({ data, color, loading }: { data: number[], color: string, loading: boolean }) => {
|
| 66 |
if (loading || data.length === 0) return <div style={{ height: 40 }} />;
|
| 67 |
|
| 68 |
+
// Safeguard: Ensure we have at least 2 points to draw a line,
|
| 69 |
+
// or handle the single point case by duplicating it.
|
| 70 |
+
const chartData = data.length === 1 ? [data[0], data[0]] : data;
|
| 71 |
+
|
| 72 |
+
const min = Math.min(...chartData);
|
| 73 |
+
const max = Math.max(...chartData);
|
| 74 |
const range = max - min || 1;
|
| 75 |
const width = 200;
|
| 76 |
const height = 40;
|
| 77 |
|
| 78 |
+
const points = chartData.map((val, i) => {
|
| 79 |
+
const x = (i / (chartData.length - 1)) * width;
|
| 80 |
const y = height - ((val - min) / range) * height;
|
| 81 |
+
// Final NaN safeguard
|
| 82 |
+
return `${isNaN(x) ? 0 : x},${isNaN(y) ? height : y}`;
|
| 83 |
}).join(' ');
|
| 84 |
|
| 85 |
const areaPoints = `${points} ${width},${height} 0,${height}`;
|