UNPKG

@lunit/oui

Version:

Lunit Oncology UI components

35 lines (34 loc) 852 B
export function parseStringValToNumber(val) { const value = val.endsWith('%') ? val.slice(0, -1) : val; return parseInt(value, 10); } export function adjustBarSegmentWidth(value) { if (value === 0) return 0; const adjusted = Math.floor((value / 100) * 97); return adjusted + 4; } export function adjustBarLabelPosition(value) { if (value === 0) return 1; if (value === 1) return 4; if (value === 100) return 98; const adjusted = Math.floor((value / 100) * 93); return adjusted + 6; } 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; }