Skip to content

feat(plotly): add reactive funnel, funnelarea and strip selection support#9044

Merged
Light2Dark merged 28 commits intomarimo-team:mainfrom
axsseldz:feat/reactive-plotly-funnel
Apr 13, 2026
Merged

feat(plotly): add reactive funnel, funnelarea and strip selection support#9044
Light2Dark merged 28 commits intomarimo-team:mainfrom
axsseldz:feat/reactive-plotly-funnel

Conversation

@axsseldz
Copy link
Copy Markdown
Contributor

@axsseldz axsseldz commented Apr 4, 2026

📝 Summary

Adds click-based selection support for funnel and funnelarea Plotly trace types, making them fully reactive in mo.ui.plotly.

🔍 Description of Changes

  • Frontend: shouldHandleClickSelection now handles "funnel" and "funnelarea" clicks; extractPoints returns trace-appropriate fields (x, y, label, value, percentages for funnel; label, value, percentages for funnelarea — no x/y)
  • Backend: _convert_value dispatches to _append_funnel_points_to_selection and _append_funnelarea_points_to_selection; range selections extract stages by value overlap; click selections pass through with index resync
  • Example: examples/third_party/plotly/funnel_chart.py with px.funnel, multi-trace regional funnel, and go.Funnelarea

Selection

funnel

📋 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

Copilot AI review requested due to automatic review settings April 4, 2026 02:22
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 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 13, 2026 2:31am

Request Review

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

Adds reactive selection support for Plotly funnel and funnelarea traces in mo.ui.plotly, extending both frontend click-payload extraction and backend selection conversion so these chart types behave like other reactive Plotly traces.

Changes:

  • Frontend: Treat funnel/funnelarea as click-selectable trace types and extract trace-specific fields from click payloads.
  • Backend: Convert selections for funnel (range + click cleanup) and funnelarea (click cleanup + index resync).
  • Tests/docs/examples: Add coverage, update docs, and introduce a new funnel selection example.

Reviewed changes

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

Show a summary per file
File Description
tests/_plugins/ui/_impl/test_plotly.py Adds backend tests for funnel/funnelarea click and range selection behavior.
marimo/_plugins/ui/_impl/plotly.py Implements funnel range extraction + click cleanup; adds funnelarea click cleanup.
frontend/src/plugins/impl/plotly/selection.ts Adds click selection handling and key extraction for funnel/funnelarea click payloads.
frontend/src/plugins/impl/plotly/__tests__/selection.test.ts Adds frontend unit tests for funnel/funnelarea click handling + extracted fields.
examples/third_party/plotly/funnel_chart.py New example demonstrating reactive funnel and funnelarea selections.
docs/api/plotting.md Updates docs to list funnel charts as supported for reactive selection.

Comment thread marimo/_plugins/ui/_impl/plotly.py
Comment thread marimo/_plugins/ui/_impl/plotly.py
Comment thread marimo/_plugins/ui/_impl/plotly.py Outdated
Comment thread tests/_plugins/ui/_impl/test_plotly.py Outdated
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 4 comments.

Comment thread marimo/_plugins/ui/_impl/plotly.py Outdated
Comment thread marimo/_plugins/ui/_impl/plotly.py Outdated
Comment thread marimo/_plugins/ui/_impl/plotly.py Outdated
Comment thread docs/api/plotting.md Outdated
@mscolnick
Copy link
Copy Markdown
Contributor

@axsseldz sorry looks like there are some merge conflicts again. if there are more, feel free to group some of these PRs together and branch them on top of each other

@axsseldz
Copy link
Copy Markdown
Contributor Author

axsseldz commented Apr 6, 2026

@axsseldz sorry looks like there are some merge conflicts again. if there are more, feel free to group some of these PRs together and branch them on top of each other

yeap, i'll take a look, ill let you know once its done, tyy!

axsseldz and others added 9 commits April 7, 2026 23:10
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>
- 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
Copy link
Copy Markdown
Contributor Author

axsseldz commented Apr 8, 2026

@axsseldz sorry looks like there are some merge conflicts again. if there are more, feel free to group some of these PRs together and branch them on top of each other

hey @mscolnick i think this PR and (#9012) had similar merge conflicts so i just updated both of them, either way if i keep getting these merge conflicts ill stack them, but for now both should be fine 👍

axsseldz and others added 8 commits April 8, 2026 09:21
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 3 comments.

Comment thread marimo/_plugins/ui/_impl/plotly.py
Comment thread marimo/_plugins/ui/_impl/plotly.py
Comment thread examples/third_party/plotly/funnel_chart.py Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Bundle Report

Changes will increase total bundle size by 12.8kB (0.05%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 24.84MB 12.8kB (0.05%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 384 bytes 703.39kB 0.05%
assets/index-*.js 683 bytes 602.15kB 0.11%
assets/index-*.css 290 bytes 362.29kB 0.08%
assets/dist-*.js -52 bytes 335 bytes -13.44%
assets/dist-*.js -234 bytes 169 bytes -58.06%
assets/dist-*.js -33 bytes 104 bytes -24.09%
assets/dist-*.js -166 bytes 169 bytes -49.55%
assets/dist-*.js 56 bytes 160 bytes 53.85% ⚠️
assets/dist-*.js 6 bytes 183 bytes 3.39%
assets/dist-*.js 40 bytes 177 bytes 29.2% ⚠️
assets/dist-*.js 283 bytes 387 bytes 272.12% ⚠️
assets/dist-*.js -7 bytes 176 bytes -3.83%
assets/dist-*.js -5 bytes 164 bytes -2.96%
assets/dist-*.js 87 bytes 256 bytes 51.48% ⚠️
assets/dist-*.js -172 bytes 104 bytes -62.32%
assets/dist-*.js 155 bytes 259 bytes 149.04% ⚠️
assets/dist-*.js -72 bytes 104 bytes -40.91%
assets/dist-*.js -62 bytes 102 bytes -37.8%
assets/dist-*.js 35 bytes 137 bytes 34.31% ⚠️
assets/dist-*.js 17 bytes 276 bytes 6.56% ⚠️
assets/dist-*.js 243 bytes 403 bytes 151.88% ⚠️
assets/dist-*.js -119 bytes 137 bytes -46.48%
assets/JsonOutput-*.js -1 bytes 336.29kB -0.0%
assets/edit-*.js -42.36kB 329.61kB -11.39%
assets/layout-*.js 56.26kB 185.91kB 43.39% ⚠️
assets/slides-*.js 360 bytes 116.37kB 0.31%
assets/panels-*.js -3.15kB 45.36kB -6.5%
assets/state-*.js 192 bytes 24.05kB 0.8%
assets/RenderHTML-*.js 60 bytes 5.01kB 1.21%
assets/ttcn-*.js 7 bytes 64 bytes 12.28% ⚠️
assets/ttcn-*.js -7 bytes 57 bytes -10.94%
assets/button-*.js 93 bytes 3.93kB 2.43%

Files in assets/index-*.js:

  • ./src/plugins/impl/plotly/selection.ts → Total Size: 7.39kB

@Light2Dark
Copy link
Copy Markdown
Collaborator

There's some merge conflicts.

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.

Comment thread marimo/_plugins/ui/_impl/plotly.py
Comment thread marimo/_plugins/ui/_impl/plotly.py
@Light2Dark Light2Dark merged commit b95d26d into marimo-team:main Apr 13, 2026
24 checks passed
@axsseldz axsseldz changed the title feat(plotly): add reactive funnel and funnelarea selection support feat(plotly): add reactive funnel, funnelarea and strip selection support Apr 13, 2026
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.

5 participants