Skip to content

Fix #140: Add ability to disable automatic showSelected on legends#292

Open
ANAMASGARD wants to merge 9 commits intomasterfrom
fix/legend-without-showSelected
Open

Fix #140: Add ability to disable automatic showSelected on legends#292
ANAMASGARD wants to merge 9 commits intomasterfrom
fix/legend-without-showSelected

Conversation

@ANAMASGARD
Copy link
Copy Markdown
Contributor

@ANAMASGARD ANAMASGARD commented Jan 23, 2026

Issue

FIXES #140

Problem

Using aes(color=variable) forces showSelected behavior on the legend with no opt-out.

This PR { First commit }

Adds failing test proposing showSelected=character() to disable automatic selector.

Screenshot From 2026-01-23 18-03-07

- Add check for showSelected=character() to opt out of auto-selector
- Clear legend when user explicitly disables showSelected
- Selector not created in info when opted out
- Legend still renders with entries (display-only)

FIXES  #140
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.72%. Comparing base (a5731da) to head (cac3261).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #292   +/-   ##
=======================================
  Coverage   77.71%   77.72%           
=======================================
  Files         164      164           
  Lines        8769     8771    +2     
  Branches      555      555           
=======================================
+ Hits         6815     6817    +2     
  Misses       1954     1954           
Flag Coverage Δ
javascript 95.46% <ø> (ø)
r 69.58% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tdhock
Copy link
Copy Markdown
Collaborator

tdhock commented Jan 23, 2026

No obvious timing issues in HEAD=fix/legend-without-showSelected
Comparison Plot

Generated via commit cac3261

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 2 minutes and 32 seconds
Installing different package versions 15 seconds
Running and plotting the test cases 3 minutes and 4 seconds

@ANAMASGARD ANAMASGARD requested a review from tdhock January 23, 2026 15:14
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

ANAMASGARD commented Jan 23, 2026

Screenshot From 2026-01-23 20-42-45

Regarding performance

  • The slight slowdown is due to the additional check for showSelected = character().
  • This check is O(1) and runs once per legend per layer.
  • Happy to optimize if needed, but the impact { slowdown } seems minimal.
  • The ghpages test failure is unrelated , All 2116 other tests pass, including the 8 new legend tests.

Comment thread R/z_animintHelpers.R Outdated
Comment on lines +33 to +34
## Proposed API: empty character vector disables auto showSelected from legend
## This is consistent with existing API where showSelected accepts character vectors
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this API idea, thanks!

But I don’t know if this is the right approach.
Can you please re-do https://tdhock.github.io/2024-07-10-figure-scatter-qsip/ with this new code so we can see the result?

@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock! Done — here is the re-done visualization:

I added a 4th plot "NEW: legend with color, no auto showSelected" that demonstrates the fix for #140 :-

  • Plot 3 ("limitation"): segments have showSelected1="comparison" -> clicking legend FILTERS segments.
  • Plot 4 ("NEW"): segments use showSelected=character() -> clicking legend does NOT filter segments.

Confirmed in plot.json: newFeature legend has "selector": null and segment geoms have no showSelected1 key.

Please let me know if this is the result you were expecting and review it , thank you .

@tdhock
Copy link
Copy Markdown
Collaborator

tdhock commented Mar 18, 2026

ok this is definitely better, but the legend in the new plot is non-interactive.
can you please add a test that fails? (click on legend in new plot, selection should change)
then fix?

@ANAMASGARD ANAMASGARD requested a review from tdhock March 19, 2026 12:40
Copy link
Copy Markdown
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

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

please remove empty lines in test_that blocks

@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

ANAMASGARD commented Mar 19, 2026

Also Sir @tdhock Sorry to tell you that in the gallery by mistake without your permission I merged it.
I was actually updating the chip-seq screenshot, pushed it to upstream, it merged it and closed the PR sorry I reverted back, Sorry Again.

@ANAMASGARD ANAMASGARD requested a review from tdhock March 19, 2026 23:48
Copy link
Copy Markdown
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

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

instead of testing not null, test the value

Comment thread tests/testthat/test-renderer2-legend-without-showSelected.R Outdated
@tdhock
Copy link
Copy Markdown
Collaborator

tdhock commented Mar 20, 2026

please can you update https://anamasgard.github.io/2024-07-10-figure-scatter-qsip ?

@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Updated :- https://anamasgard.github.io/2024-07-10-figure-scatter-qsip/
Please review .

@ANAMASGARD ANAMASGARD requested a review from tdhock March 21, 2026 13:48
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.

legend forces showSelected, no way to opt out

2 participants