Add 95th percentile line to overview network traffic graph

This commit is contained in:
2026-01-25 19:29:13 -05:00
parent db3993aa48
commit b6a901ea36

View File

@@ -1784,6 +1784,16 @@
hasData: downloadData.some(v => v > 0) || uploadData.some(v => v > 0)
});
// Calculate 95th percentile from combined traffic
const combinedTraffic = downloadData.map((d, i) => d + (uploadData[i] || 0));
const sortedTraffic = [...combinedTraffic].filter(v => v > 0).sort((a, b) => a - b);
let p95Value = 0;
if (sortedTraffic.length > 0) {
const p95Index = Math.floor(sortedTraffic.length * 0.95);
p95Value = sortedTraffic[Math.min(p95Index, sortedTraffic.length - 1)];
}
const p95Data = Array(downloadData.length).fill(p95Value);
// Create a local formatRate function that's guaranteed to be in scope
const formatRateForChart = (bytesPerSec) => {
if (typeof bytesPerSec !== 'number' || isNaN(bytesPerSec)) {
@@ -1816,6 +1826,18 @@
fill: true,
pointRadius: 0,
pointHoverRadius: 4,
},
{
label: '95th Percentile (' + formatRateForChart(p95Value) + ')',
data: p95Data,
borderColor: 'rgb(239, 68, 68)',
backgroundColor: 'transparent',
borderDash: [5, 5],
tension: 0,
fill: false,
pointRadius: 0,
pointHoverRadius: 0,
borderWidth: 2,
}
]
},