Skip to content

Pie chart: surplus slivers close smoothly; residual surplus no longer a labeled candidate - #630

Open
skaphan wants to merge 2 commits into
artoonie:mainfrom
skaphan:pie-surplus-sliver-fix
Open

Pie chart: surplus slivers close smoothly; residual surplus no longer a labeled candidate#630
skaphan wants to merge 2 commits into
artoonie:mainfrom
skaphan:pie-surplus-sliver-fix

Conversation

@skaphan

@skaphan skaphan commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Two pie fixes, one found during review of the other.

1. Surplus slivers close smoothly instead of leaving a white gap

When an elected candidate's surplus transfers, the grayed-out sliver of their slice was removed at full size at the start of the consolidate phase, leaving a white gap that neighboring slices then closed over. The pie bundle now retains the transfer sub-slice as a zero-value entry in the closing transition's data, so the keyed data join tweens it shut instead of exit-removing it at full size.

Correction to the original description (and to @artoonie's question above — sorry for the wild-goose chase): I claimed the 2013 Minneapolis Park Board election had three surplus rounds. It has one (round 9→10, ~1,829 votes, about 3.9% of the pie), which is why the gap was hard to spot there. The best data for seeing the original bug is this repo's own macomb-multiwinner (Eastpointe 2019): round 4's surplus transfers 50.9 of 400 votes, so the disappearing sliver is ~12.7% of the circle — unmissable. Round 2 shows the small-sliver case (10 votes).

2. Residual surplus no longer appears as a candidate (the overlapping-labels screenshot)

The overlap @artoonie found while testing turned out to be a second, separate bug, and this branch now fixes it too.

rcvis injects residual surplus into the tally as a Residual Surplus pseudo-candidate. The component only knew the lowercase residual surplus form that raw RCTab files carry (as a transfer destination), so the title-cased tally entry walked past every check and was treated as an ordinary candidate: it got a slice, a color, a label, a place in the active-votes denominator — and a position in the slice shuffle. Inactive Ballots is pinned to the end of the slice order; whenever the shuffle happened to seat Residual Surplus in the last active position (~1-in-5 for this field size), the two near-zero slices sat adjacent at 12 o'clock and their labels superimposed. That's the screenshot.

The component now recognizes residual surplus case-insensitively and drops it entirely: no slice, no label, excluded from the live-votes denominator, transfer references absorbed silently. A stranded rounding remainder (0.0224 votes here) is held by nobody; a wedge too thin to see shouldn't get a label pointing at nothing.

One caveat for completeness: the label overlap-suppression logic measures text with getBBox(), which returns 0×0 when the chart is initialized while hidden (e.g. load on the Bar tab, then switch to Pie) — so on that path suppression is inert for any coincident labels, independent of this fix. With the residual gone this election has no coincident pair left, but that's a separate, smaller issue; happy to address it separately if you'd like.

Test plan

  • Upload macomb-multiwinner (Eastpointe 2019); pie shows no Residual Surplus slice or label in any round; Inactive Ballots labeled normally from round 4
  • Round 4 surplus animation: sliver sweeps closed (hatched) instead of popping to a white gap; round 2 same for the small sliver
  • Reload several times: no label collision under any shuffle order
  • 2013 Minneapolis Park Board round 9→10 surplus still animates correctly

🤖 Generated with Claude Code

When an elected candidate's surplus transfers, the hatched sliver was
deleted at full size at the start of the consolidate phase — a white
gap in the pie that neighboring slices then closed over. The closing
data now carries the transfer sub-slice as a zero-value entry, so the
same angular tween that closes eliminated candidates' slices closes
the sliver too.

Bundle built from rcv-pie-chart acb3dd7 (source fix in
PieChartGraphics.svelte updatePie).

Co-Authored-By: Claude Fable 5
@artoonie

artoonie commented Aug 10, 2026

Copy link
Copy Markdown
Owner

I'm testing this looking at the 2013 Minneapolis Park but don't see the white gap you're referring to -- the only surplus transfer is round 10->11 and the gap is too small to notice anything. Can you help me find the issue you encountered?

Separately, while testing this, I noticed an odd behavior:
On the macomb-multiwinner config, if you load the page on the "Bar" tab, then switch to "Pie", the words overlap. If you refresh the page on "Pie" or change rounds, the issue does not appear.

Screenshot 2026-08-10 at 9 11 11 AM

macomb-multiwinner_ouALmBP.json

@skaphan

skaphan commented Aug 10, 2026 via email

Copy link
Copy Markdown
Contributor Author

@skaphan

skaphan commented Aug 10, 2026 via email

Copy link
Copy Markdown
Contributor Author

Fixes the overlapping-labels behavior reported in review (Eastpointe /
macomb-multiwinner): rcvis injects residual surplus into the tally as a
"Residual Surplus" pseudo-candidate, which the component treated as an
ordinary candidate — a near-zero slice, shuffled among the real ones,
labeled, and counted in the active-votes denominator. When the shuffle
seated it beside the end-pinned Inactive Ballots slice, the two labels
superimposed at the top of the pie.

The component now recognizes residual surplus case-insensitively (raw
RCTab files carry it lowercase, as a transfer destination only) and
drops it entirely: no slice, no label, excluded from the live-votes
denominator, and transfer references to it are absorbed silently. A
stranded rounding remainder is held by nobody, so a wedge too thin to
see no longer gets a label pointing at nothing.

Source change in the pie component's candidate-order / active-votes /
transfer paths; verified against this election's data with the rcvis-
style tally injection reproduced.

Co-Authored-By: Claude Fable 5
@skaphan skaphan changed the title Pie chart: surplus slivers close smoothly instead of leaving a white gap Pie chart: surplus slivers close smoothly; residual surplus no longer a labeled candidate Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants