Isolate a series on legend double-click (Plotly-style) - #506
Conversation
Double-clicking a legend row now shows only that series or category; a
second double-click on the row that is already alone restores every entry
(Plotly's legenddoubleclick model). Single click keeps toggling exactly as
before. `xy.legend(isolate=False)` opts out, following the same default-on,
opt-out-only wire rule as `toggle` and `highlight`, and is independent of
`toggle`: with `toggle=False` single clicks stay inert while double-click
still isolates.
Single clicks commit immediately -- no Plotly-style 300 ms disambiguation
delay -- so by the time `dblclick` fires the gesture's first click has
already toggled the row. The client ignores the second click of the burst
(`event.detail >= 2`) and decides isolate-vs-restore against the
pre-gesture state, so the end state is exactly what a fresh isolate would
produce. Each changed row goes through the ordinary toggle path (one
`legend_toggle` message and one `xy:legendtoggle` per row, in legend
order); category re-filtering runs once per affected trace after the whole
batch; one new `xy:legendisolate {name, isolated, traces, category?}` event
names the gesture. The second press is preventDefault'ed on mousedown so the
label text is not selected.
Spec: interaction.md §10 documents the gesture and its recorded limits, and
the §3 event table now lists `xy:legendtoggle` (it was dispatched but
missing from the "whole surface" list) and `xy:legendisolate`;
wire-protocol.md notes isolate is not a message of its own. Docs gain a
"Toggle and Isolate Series" section. Browser probes cover the default,
`isolate=False` (byte-identical pre-existing toggle behavior) and
`toggle=False` paths, asserting buffers, row state, wire messages and events.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (5)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughAdds Plotly-style legend double-click isolation and restoration. Adds an independent ChangesLegend isolation
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This change adds legend double-click isolation and restoration while preserving existing single-click behavior and providing an opt-out; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant LegendRow
participant ChartView
participant Kernel
participant ChartRoot
LegendRow->>ChartView: Double-click linked legend entry
ChartView->>ChartView: Isolate or restore linked rows
ChartView->>Kernel: Send legend_toggle for changed rows
ChartView->>ChartRoot: Dispatch xy:legendtoggle events
ChartView->>ChartRoot: Dispatch xy:legendisolate event
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Closes #505.
What
Double-clicking a legend row shows only that series/category; double-clicking the row that is already alone restores every entry (Plotly's
legenddoubleclickmodel). Single click keeps toggling one entry exactly as before. Newxy.legend(isolate=False)opts out — same default-on, opt-out-only wire rule astoggle/highlight, and independent oftoggle(withtoggle=False, single clicks are inert while double-click still isolates).How
dblclickfires, the burst's first click has already toggled the row; the client ignores the second click (event.detail >= 2) and decides isolate-vs-restore against the pre-gesture state. End state equals a fresh isolate; the transient first-click frame is the recorded cost (spec §10)._legendToggleis factored into_legendSetOff(row chrome, view-held off-sets, GPU flag, kernel message) +_legendApplyBatch(category re-filter once per affected trace, badges, pick). Isolate walks all linked rows across every legend box in legend order; each changed row ships its ownlegend_toggleandxy:legendtoggle; onexy:legendisolate {name, isolated, traces, category?}names the gesture (not fired when nothing changed).preventDefaulted onmousedownso the label text is not selected; single presses keep native focus/selection rules.Spec / docs
spec/api/interaction.md§10: the gesture and its limits. §3 event table now listsxy:legendtoggle— it was dispatched but missing from the "those nine are the whole surface" list — plusxy:legendisolate.spec/design/wire-protocol.md: isolate is not a message of its own.docs/components/legends.md: new "Toggle and Isolate Series" section with a demo.Tests
test_legend_isolate_option: wire opt-out, independence fromtoggle, publicLegendpositional order still binds.isolate=False(byte-identical pre-existing toggle behavior on the wire),toggle=False. They assert vertex-buffer row counts, rowdata-xy-legend-offstate, the exactlegend_togglemessage sequence, and thexy:legendtoggle/xy:legendisolateevents.tests/suite,ruff check/ruff format --check,ty check(no new diagnostics vs main), docs-site tests (119 passed) run locally.Summary by CodeRabbit
New Features
Documentation