Fix 95th percentile update in network traffic chart
This commit is contained in:
@@ -1681,9 +1681,23 @@
|
|||||||
return (isNaN(num) || num === null || num === undefined) ? 0 : num;
|
return (isNaN(num) || num === null || num === undefined) ? 0 : num;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
chart.data.labels = labels.slice(-20);
|
chart.data.labels = labels.slice(-20);
|
||||||
chart.data.datasets[0].data = downloadData;
|
chart.data.datasets[0].data = downloadData;
|
||||||
chart.data.datasets[1].data = uploadData;
|
chart.data.datasets[1].data = uploadData;
|
||||||
|
if (chart.data.datasets[2]) {
|
||||||
|
chart.data.datasets[2].data = p95Data;
|
||||||
|
chart.data.datasets[2].label = '95th Percentile (' + formatRate(p95Value) + ')';
|
||||||
|
}
|
||||||
chart.update('none');
|
chart.update('none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user