(value: number | string, basis: number)
| 389 | type HitTestMatch = CartesianHitTestMatch | PieHitTestMatch | CandlestickHitTestMatch; |
| 390 | |
| 391 | const parseNumberOrPercent = (value: number | string, basis: number): number | null => { |
| 392 | if (typeof value === 'number') return Number.isFinite(value) ? value : null; |
| 393 | if (typeof value !== 'string') return null; |
| 394 | |
| 395 | const s = value.trim(); |
| 396 | if (s.length === 0) return null; |
| 397 | |
| 398 | if (s.endsWith('%')) { |
| 399 | const pct = Number.parseFloat(s.slice(0, -1)); |
| 400 | if (!Number.isFinite(pct)) return null; |
| 401 | return (pct / 100) * basis; |
| 402 | } |
| 403 | |
| 404 | // Be permissive: allow numeric strings like "120" even though the public type primarily documents percent strings. |
| 405 | const n = Number.parseFloat(s); |
| 406 | return Number.isFinite(n) ? n : null; |
| 407 | }; |
| 408 | |
| 409 | const resolvePieCenterPlotCss = ( |
| 410 | center: PieCenter | undefined, |
no outgoing calls
no test coverage detected