@lunit/oui
Version:
Lunit Oncology UI components
19 lines (18 loc) • 438 B
JavaScript
export function parseStringValToNumber(val) {
const value = val.endsWith('%') ? val.slice(0, -1) : val;
return parseInt(value, 10);
}
export function clampNumericalPercentage(value) {
if (value >= 100)
return 100;
if (value <= 0)
return 0;
return value;
}
export function clampBarLabelPosition(value) {
if (value >= 100)
return 97;
if (value <= 0)
return 1;
return value;
}