v0.33.6
This commit is contained in:
1 parent
5dd802ae83
commit
a286355b0e
22 files changed
+447
-70
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// Stable plot ranges: percentages are absolute 0-100; unbounded metrics have
|
||||
// unit-appropriate zero-based floors, expanding only for real higher readings.
|
||||
window.rustProxyChartScale = (() => {
|
||||
const floors = { rate: 100, count: 10, ms: 100, bytes: 64 * 1024 * 1024, "bytes/s": 64 * 1024 };
|
||||
const ceilings = new Map();
|
||||
function peak(key, unit, series) {
|
||||
if (unit === "percent") return 100;
|
||||
const floor = floors[unit] ?? 1;
|
||||
let maximum = floor;
|
||||
for (const values of series) for (const value of values) {
|
||||
if (typeof value === "number" && Number.isFinite(value) && value >= 0)
|
||||
maximum = Math.max(maximum, value);
|
||||
}
|
||||
const magnitude = 10 ** Math.floor(Math.log10(maximum));
|
||||
const tick = [1, 2, 5, 10].find(n => n * magnitude >= maximum) ?? 10;
|
||||
const result = Math.max(ceilings.get(key) ?? 0, tick * magnitude);
|
||||
ceilings.set(key, result);
|
||||
return result;
|
||||
}
|
||||
function reset(prefix) {
|
||||
for (const key of ceilings.keys()) if (key.startsWith(prefix)) ceilings.delete(key);
|
||||
}
|
||||
return { peak, reset };
|
||||
})();
|
||||
Reference in new issue
Block a user