Repository navigation
fix(charts): keep pie slices proportional for extreme finite values - #1067
Conversation
dovvnloading
left a comment
There was a problem hiding this comment.
Reviewed all six changed files at e8d8426. No blocking code findings. Max-scaling occurs before aggregation, the positive/finite canonical input contract and 300-point cap make the normalization safe, both renderers preserve ordering and proportional shares, and original values are not mutated. The existing SVG overview consumes the same helper. No schema/dependency/CI changes.
Validation:
- GitHub Actions CI run 45595968214: all four required jobs passed (Windows Python including compile, pytest and perf; frontend schema/type/lint/Vitest/build; wheel install/build; POSIX permissions and focused Bash E2E). Nightly-only Playwright boot-smoke was skipped as designed.
- Independently compiled the exact
pieSlices.tsblob and exercised it and the exactPieChartMarks.tsxblob in an isolated Chromium SVG/DOM harness (fixture theme values and lightweight React/JSX adapter, not the full application). Visually inspected light/dark screenshots: equal huge values, 12 huge values including Other, mixed extremes, subnormals, and normal values; legend, tooltip handlers, overview geometry, and 1,000 additional randomized geometry cases passed. - Independently exercised the copied
_render_pie_chartimplementation with Matplotlib 3.10.8: 15 geometry, label, and SVG/PDF/PNG output checks passed. - Main has advanced three unrelated commits; compared changed paths, with no overlap with this PR.
Limitation: local GitHub checkout fails DNS, so I could not launch the full desktop app or manually exercise integrated keyboard navigation/theme switching. The targeted browser harness is supplemental, not a replacement for CI. The full CI gates are green; manual focused rendering review is complete. This is a comment review rather than an independent GitHub approval because the connected account is the PR author.
Summary
Fixes #1045. Finite positive pie values can have an overflowing sum; Matplotlib also converts inputs to float32, so values well inside the double range can overflow or underflow there. Calculate geometry and percentages from max-scaled weights in both interactive SVG (including the overview) and static publication exports.
What Changed
>1.79e308. Positive shares below 0.1% are labeled<0.1%rather than zero.Why
The maximum value is finite and positive for a valid pie, so dividing each value by it makes the geometry bounded before grouping or summing. This avoids both the double-precision sum overflow and Matplotlib's float32 input range problem without changing validation, persisted data or units. Extremely small ratios can still round to zero-width at available numeric/rendering precision; their labels explicitly indicate the small positive share.
Validation
python -m compileall -q .passes (run from the repo root - matches CI)python -m pytest -qpasses (run from the repo root - matches CI)cd web_ui && npm run checkpasses (matches CI)Local full checkout is blocked by GitHub DNS resolution. The isolated checks are not a full repo test run; the added Vitest component/geometry and pytest publication tests require CI or a configured checkout (Python 3.12 / Node 24). Focused commands:
Manual verification: generate or load a pie with values [1e308, 1e308]; check the two half-circle wedges, 50% legends and hover values, total lower bound, overview, both themes and publication exports. Repeat with 12 equal values and a very small positive slice.
UI Notes
No new UI components or styles. Labels and extreme-value geometry change; screenshots, keyboard and both-theme checks remain pending.
Additional Context
No dependency, wire-schema, data migration or CI changes. The overflow label deliberately reports a lower bound instead of fabricating a finite total; raw inputs remain available. Draft pending CI and manual review; do not merge until required checks and manual validation pass.