Skip to content

feat(plotly): add reactive strip chart selection support#9012

Open
axsseldz wants to merge 26 commits intomarimo-team:mainfrom
axsseldz:feat/reactive-plotly-strip
Open

feat(plotly): add reactive strip chart selection support#9012
axsseldz wants to merge 26 commits intomarimo-team:mainfrom
axsseldz:feat/reactive-plotly-strip

Conversation

@axsseldz
Copy link
Copy Markdown
Contributor

@axsseldz axsseldz commented Apr 3, 2026

📝 Summary

Makes px.strip fully selection-reactive in mo.ui.plotly. Strip charts are go.Box traces under the hood (boxpoints="all", transparent fill), so this PR combines the box and violin implementations from the sibling branches onto one branch.

🔍 Description of Changes

  • Frontend: added type === "box" and type === "violin" to shouldHandleClickSelection.
  • Python: ported the full box and violin implementations (_append_*, _extract_*, _build_* helpers). Strip chart reactivity comes for free through the box path.
  • Tests: violin tests.
  • Example: examples/third_party/plotly/strip_chart.pypx.strip() grouped, go.Box single-trace, and horizontal variants with live stats and mo.ui.table.

Box Selection

strip1

Click Selection

strip2

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@mscolnick @nojaf

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 9, 2026 1:41am

Request Review

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 3, 2026
@axsseldz axsseldz marked this pull request as ready for review April 3, 2026 13:57
Copilot AI review requested due to automatic review settings April 3, 2026 13:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables selection reactivity for Plotly box/violin traces (and therefore px.strip, which renders as go.Box) in mo.ui.plotly, including click-selection support in the frontend and row-level expansion/extraction on the Python side.

Changes:

  • Frontend: handle click selections for type === "box" and type === "violin".
  • Python: add box/violin selection expansion/extraction helpers and hook them into _convert_value.
  • Add extensive tests plus a new strip-chart example and docs update.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
marimo/_plugins/ui/_impl/plotly.py Adds box/violin selection expansion (click pointNumbers) and range-based extraction logic.
tests/_plugins/ui/_impl/test_plotly.py Adds unit tests covering box/violin/strip selection conversion and extraction helpers.
frontend/src/plugins/impl/plotly/selection.ts Allows click-selection handling for box/violin traces.
frontend/src/plugins/impl/plotly/__tests__/selection.test.ts Adds tests asserting click-selection eligibility for box/violin.
examples/third_party/plotly/strip_chart.py New example demonstrating reactive strip-chart selection workflows.
docs/api/plotting.md Updates documentation of which Plotly chart types support reactive selection.

@mscolnick mscolnick requested review from kirangadhave and removed request for Light2Dark, akshayka and manzt April 3, 2026 18:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

axsseldz and others added 5 commits April 3, 2026 20:01
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>
axsseldz and others added 3 commits April 8, 2026 01:31
- 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>
axsseldz and others added 12 commits April 8, 2026 09:02
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>
Adds funnel/funnelarea chart support from feat/reactive-plotly-funnel so
that both branches can merge into main independently without conflicts.
Includes funnel/funnelarea trace types, test cases, and docs updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The cross-branch merge left two competing implementations of
_append_box_points_to_selection and its helpers, plus duplicate
_build_waterfall_point and _append_map_scatter_points_to_selection.
Python silently used the last definition; pyright caught all six
[no-redef] errors in CI. Removes the dead first copies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants