Repository navigation
Conversation
A redraw without a recalc (for example a resize through relayout or react) reuses the calcdata points. The plot step set labelExtraX, labelExtraY and yLabelMid only for labels that were outside on the current draw. A label that moved back inside kept the values of the previous draw. scootLabels then treated the label as an outside label, and plotTextLines drew its old leader line and shifted the other labels. Reset this state for every slice at the start of each draw. Fixes plotly#4979 and plotly#5616. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Thanks for the PR! We'll take a closer look and follow up. |
KoolADE85
self-requested a review
October 26, 2026 20:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the stale leader lines and label offsets that stay on a pie after its labels move back inside.
Fixes #4979 and #5616.
Cause
A redraw without a recalc reuses the calcdata points. A resize through
Plotly.relayoutorPlotly.reactis such a redraw.plotinsrc/traces/pie/plot.jssetlabelExtraX,labelExtraYandyLabelMidonly for the labels that were outside on the current draw. A label that moved back inside kept the values of the previous draw.scootLabelsthen treated the label as an outside label, andplotTextLinesdrew its old leader line. The other outside labels moved to avoid the stale label.Fix
Reset this state for every slice at the start of each draw. The reset also clears the state of hidden slices, so
plotTextLinesno longer draws a line for a hidden slice.Tests
pie_test.js(pie relayoutsuite). The test draws a pie at 300x300 px, where some labels need leader lines. Then the test callsPlotly.relayoutto 1000x1000 px. The test expects the same leader lines and label positions as a new plot at 1000x1000 px. Without the fix, the resized plot has 3 leader lines where the new plot has none, and 3 labels are 2 to 8 px lower.pie,funnelarea,legend,sunburst,treemapandiciclesuites in headless Chrome on Windows. Theuniformtext"react with new uniform text options" test fails for pie, funnelarea, sunburst and treemap on this machine with and without the change. All other tests pass.npm run lintandnpm run typecheckpass.npm run test-syntaxreports the samegetComputedStylecount error with and without the change on this Windows checkout.Screenshots
The same figure (8 slices,
textposition: 'auto'), first drawn at 300x300 px and then resized withPlotly.relayoutto 700x700 px.Before:
After:
The change moves no image baselines that I know of. No mock resizes a pie after the first draw.
draftlogs/0000_fix.mdholds a placeholder number. I will rename it to the number of this pull request.🐦
I used Claude Code to write this change.