(value: number | string, basis: number)
| 62 | }; |
| 63 | |
| 64 | const parseNumberOrPercent = (value: number | string, basis: number): number | null => { |
| 65 | if (typeof value === 'number') return Number.isFinite(value) ? value : null; |
| 66 | if (typeof value !== 'string') return null; |
| 67 | |
| 68 | const s = value.trim(); |
| 69 | if (s.length === 0) return null; |
| 70 | |
| 71 | if (s.endsWith('%')) { |
| 72 | const pct = Number.parseFloat(s.slice(0, -1)); |
| 73 | if (!Number.isFinite(pct)) return null; |
| 74 | return (pct / 100) * basis; |
| 75 | } |
| 76 | |
| 77 | // Be permissive: allow numeric strings like "120" even though the public type primarily documents percent strings. |
| 78 | const n = Number.parseFloat(s); |
| 79 | return Number.isFinite(n) ? n : null; |
| 80 | }; |
| 81 | |
| 82 | const resolveCenterPlotCss = ( |
| 83 | center: PieCenter | undefined, |
no outgoing calls
no test coverage detected