allocationText fix
This commit is contained in:
@@ -251,3 +251,11 @@ export function computeInterceptSlope(time0, price0, time1, price1) {
|
||||
export function defined(v) {
|
||||
return v !== undefined && v !== null
|
||||
}
|
||||
|
||||
export function toPrecision(value, significantDigits = 3) {
|
||||
if (!isFinite(value)) return value.toString(); // Handle Infinity and NaN
|
||||
if (value === 0) return "0"; // Special case for 0
|
||||
const magnitude = Math.floor(Math.log10(Math.abs(value)));
|
||||
const decimalsNeeded = Math.max(0, significantDigits - 1 - magnitude);
|
||||
return value.toFixed(decimalsNeeded); // Use toFixed to completely avoid scientific notation
|
||||
}
|
||||
Reference in New Issue
Block a user