Skip to content

Commit 4df751c

Browse files
committed
chore: format viewer RTT chart
Signed-off-by: kryptocodes <srivatsantb@gmail.com>
1 parent 8108799 commit 4df751c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

services/control-plane/src/admin-ui.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,15 @@ function formatCount(value: number) {
10571057
return String(value);
10581058
}
10591059

1060+
function formatMs(value: number) {
1061+
if (!Number.isFinite(value) || value <= 0) return '0ms';
1062+
if (value >= 1000) {
1063+
const s = value / 1000;
1064+
return `${Number.isInteger(s) ? s : s.toFixed(1)}s`;
1065+
}
1066+
return `${Math.round(value)}ms`;
1067+
}
1068+
10601069
function bucketSizeLabel(windowHours: number, bucketCount: number) {
10611070
const seconds = (windowHours * 3600) / Math.max(1, bucketCount);
10621071
if (seconds < 3600) {
@@ -1381,7 +1390,7 @@ function viewerRttChartSvg(series: AnalyticsData['viewerRttSeries'], windowHours
13811390
const v = (maxY * t) / 4;
13821391
const y = baseY - (plotH * t) / 4;
13831392
return `<line x1="${padL}" y1="${y.toFixed(1)}" x2="${padL + plotW}" y2="${y.toFixed(1)}" stroke="${VIZ.grid}" stroke-width="1"/>`
1384-
+ `<text x="${(padL - 8).toFixed(1)}" y="${(y + 3).toFixed(1)}" text-anchor="end" font-size="10" fill="${VIZ.axis}">${Math.round(v)}ms</text>`;
1393+
+ `<text x="${(padL - 8).toFixed(1)}" y="${(y + 3).toFixed(1)}" text-anchor="end" font-size="10" fill="${VIZ.axis}">${formatMs(v)}</text>`;
13851394
}).join('');
13861395

13871396
const p50Segments: Array<Array<{ x: number; y: number }>> = [];

0 commit comments

Comments
 (0)