feat(plotly): add reactive box plot selection support#9010
feat(plotly): add reactive box plot selection support#9010Light2Dark merged 24 commits intomarimo-team:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds selection reactivity for Plotly box plots in mo.ui.plotly, enabling click and drag selections to produce row-level selection payloads in Python.
Changes:
- Frontend: forward click events for
type === "box"traces so selections reach Python. - Backend: expand box click
pointNumbersinto per-sample rows and add range-based extraction for box traces when Plotly doesn’t send individual points. - Tests/docs/examples: add box selection tests, update plotting docs, and add a new box selection example.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
marimo/_plugins/ui/_impl/plotly.py |
Implements box selection expansion and range-based extraction, and wires it into _convert_value. |
tests/_plugins/ui/_impl/test_plotly.py |
Adds extensive Python tests for box selection behavior (click/range/orientation/multi-trace). |
frontend/src/plugins/impl/plotly/selection.ts |
Treats box trace clicks as selection events to forward to Python. |
frontend/src/plugins/impl/plotly/__tests__/selection.test.ts |
Adds a unit test asserting box clicks are accepted. |
frontend/src/plugins/impl/plotly/__tests__/PlotlyPlugin.test.tsx |
Adds an integration-style test that a box click triggers setValue. |
examples/third_party/plotly/box_chart.py |
New example showcasing reactive box selection patterns. |
docs/api/plotting.md |
Documents that box plots now support reactive selections. |
d5a2b30 to
2606ee9
Compare
2606ee9 to
0f45c3f
Compare
|
happy to merge the violin plot PR once ready, thanks for working on these |
Resolves conflicts between waterfall (merged to main) and strip/box/violin additions. Both feature sets are now present: waterfall handlers are inserted before the box/violin handlers in _convert_value, and all function definitions are included. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolves conflicts between waterfall (merged to main) and funnel additions. Both feature sets included: waterfall handlers inserted before funnel handlers in _convert_value, all function definitions and tests from both branches kept. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
hey @Light2Dark, just updated the violin plot PR (#9011), should be fine now, also, i'll take care of the merge conflicts in this PR once the other gets merged 🫡 |
- Fix unsafe np.asarray(val_data, dtype=np.float64) call: wrap in try/except and fall back to element-wise extraction when val_data contains None or non-numeric entries (comment 1) - Fix off-by-one in overlap check: use >= val_min (inclusive lower bound) in both the numpy fast path and the pure-Python fallback, consistent with bar selection behavior (comment 2) - Correct docstring: click path strips empty placeholders and re-syncs indices; it does not deduplicate (comment 3) - Update docs to mention funnelarea support explicitly (comment 4) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merges violin plot and area chart support from main while preserving box/strip plot additions. `hasAreaTrace` added to TS, both `_append_box_points_to_selection` and `_append_violin_points_to_selection` coexist in Python with their full helper function hierarchies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Syncs strip chart support into box branch so both can merge into main independently without conflicts. Adds strip chart example, strip test section, and updated supported-charts documentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Thanks! For merge path, probably this one and then the strip chart one #9012? They look to share a lot of logic, maybe with different names and some differences. Also left a comment on #9011, which can be addressed in a separate PR. |
0f45c3f to
4d2ec4c
Compare
06ef70f to
1087c03
Compare
|
@axsseldz happy to get this merged in once copilot comments are resolved |
thanks!, ill make the changes later today(: |
|
@Light2Dark the comments should be resolved, also, i'm planning to address these type of behaviors [ i spotted some similar behaviors in other plotly charts] (#9011 (review)) in another PR, after this PR, (#9044), and (#9012) get merged, so i can sync all plotly charts ive worked on and behave properly, pls lmk if the other two PRs need any changes so i can address them(: |
Bundle ReportChanges will increase total bundle size by 12.8kB (0.05%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
Files in
|
## 📝 Summary
Makes
go.Box(andpx.box) plots fully selection-reactive inmo.ui.plotly. Users can now drag a box/lasso, click a box body, or click individual jittered points to get row-level data in Python.🔍 Description of Changes
type === "box"toshouldHandleClickSelectionso box click events are forwarded to Python._append_box_points_to_selectionwhich handles three cases: range/lasso with individual points already sent by Plotly, range/lasso without points (extract from figure data), and click events (expandpointNumbersinto individual rows). Supports vertical/horizontal orientation and categorical axes.examples/third_party/plotly/box_chart.py— three chart variants (single-trace, grouped, horizontal) each with a live stats summary andmo.ui.table.Selection
Click Selection
📋 Pre-Review Checklist
✅ Merge Checklist
@mscolnick @nojaf