fix(historial): clamp sparkline bar height between 15-90% to prevent overflow
CI / Build Native (push) Failing after 39s
CI / Build Native (push) Failing after 39s
When range=0 (1 run or all same profit), use absolute scale with clamped heightPct
This commit is contained in:
@@ -546,10 +546,12 @@
|
||||
if (!data.length) return [];
|
||||
const max = Math.max(...data.map(d => d.profit));
|
||||
const min = Math.min(...data.map(d => d.profit));
|
||||
const range = Math.abs(max - min) || 1;
|
||||
const range = Math.abs(max - min);
|
||||
const useAbsoluteScale = range === 0 || max === 0;
|
||||
const ref = useAbsoluteScale ? Math.max(Math.abs(max), 1) : range;
|
||||
return data.map(d => ({
|
||||
...d,
|
||||
heightPct: d.profit === 0 ? 5 : Math.max(10, Math.abs(d.profit) / range * 90)
|
||||
heightPct: d.profit === 0 ? 50 : Math.max(15, Math.min(90, Math.abs(d.profit) / ref * 90))
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user