Skip to content

Conversation

@emilykl
Copy link
Contributor

@emilykl emilykl commented Dec 8, 2025

Closes #7660

Fixes issue where some traces in stacked area charts were not rendering their fill correctly after certain sequences of hide/show operations in the legend.

Steps to test

Reproduce existing issue

  1. Go to this Codepen (from the docs)
  2. Follow the exact reproduction steps described in 7660:
  • Double-click "trace 1" to show "trace 1" only
  • Click "trace 1" again
  • Now plot is empty
  • Double click any trace to show all traces again
  1. The orange trace should be missing a fill. This is the bug.
Screenshot 2025-12-08 at 5 47 23 PM

Confirm that this PR fixes the issue

  1. In the Codepen, replace the plotly.js script src with the build for this branch from the CI: https://output.circle-artifacts.com/output/job/c4caeb45-0a0b-4e23-97b6-ebb26b8561c8/artifacts/0/dist/plotly.js
  2. Repeat the steps under (2) above
  3. All trace fills should render normally.
Screenshot 2025-12-08 at 5 49 23 PM

@emilykl emilykl marked this pull request as ready for review December 8, 2025 22:59
@emilykl emilykl requested a review from camdecoster December 8, 2025 23:00
Comment on lines 86 to 93
// Clear any existing fill element references to ensure clean state
// This prevents stale references when fill configuration changes
trace._ownFill = null;
trace._nextFill = null;

var fillData = [];
if(trace._ownfill) fillData.push('_ownFill');
if(trace._nexttrace) fillData.push('_nextFill');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're making _ownFill and _nextFill null, the if checks will always fail. So, let's delete them.

Suggested change
// Clear any existing fill element references to ensure clean state
// This prevents stale references when fill configuration changes
trace._ownFill = null;
trace._nextFill = null;
var fillData = [];
if(trace._ownfill) fillData.push('_ownFill');
if(trace._nexttrace) fillData.push('_nextFill');
// Clear any existing fill element references to ensure clean state
// This prevents stale references when fill configuration changes
trace._ownFill = null;
trace._nextFill = null;
var fillData = [];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camdecoster Tragically, _ownFill and _ownfill, as well as _nextFill and _nexttrace, are separate variables. 🙃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough. I have words about this, but I won't include them here publicly.

@emilykl emilykl force-pushed the fix-stacked-area-hide-show-bug branch from bcd7e49 to 44bc554 Compare December 9, 2025 22:48
@ndrezn ndrezn assigned emilykl and unassigned camdecoster Dec 10, 2025
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.

[BUG]: filled area plots having trouble showing trace in correct position after hiding/showing traces

3 participants