Skip to content

Conversation

@nojaf
Copy link
Contributor

@nojaf nojaf commented Jan 8, 2026

📝 Summary

Similar to #7546, we also want Plotly bar charts to be reactive

🔍 Description of Changes

image

I tried to stay as close as possible to how this works in Altair.
Happy to address any remarks you might have.

📋 Checklist

  • I have read the contributor guidelines.
  • 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).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.
@nojaf nojaf requested a review from akshayka as a code owner January 8, 2026 09:21
@vercel
Copy link

vercel bot commented Jan 8, 2026

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

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 8, 2026 2:50pm
Copy link
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

This pull request adds support for reactive bar chart selections in Plotly visualizations. Similar to the existing support for scatter plots, heatmaps, and other chart types, users can now select bars in Plotly bar charts using box selection and retrieve the selected bar data as a list of dictionaries in Python.

Key changes:

  • Added bar chart extraction logic with both numpy-optimized and fallback implementations
  • Comprehensive test coverage with 15 new test cases covering various bar chart scenarios
  • Included a detailed example demonstrating the feature with multiple bar chart types

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
marimo/_plugins/ui/_impl/plotly.py Core implementation: added _extract_bars_numpy, _extract_bars_fallback, _extract_bars_from_range, and _append_bar_items_to_selection functions to handle bar chart selection logic for both vertical and horizontal bars with categorical and numeric axes
tests/_plugins/ui/_impl/test_plotly.py Comprehensive test suite with 15 tests covering basic selection, horizontal/vertical orientation, categorical/numeric axes, stacked/grouped bars, edge cases, and numpy/fallback parity
examples/third_party/plotly/bar_chart.py Example notebook demonstrating reactive bar chart selections with simple vertical, stacked, grouped, and horizontal bar charts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit f038d40 into marimo-team:main Jan 8, 2026
31 of 41 checks passed
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev182

@dmadisetti dmadisetti added the enhancement New feature or request label Jan 8, 2026
mscolnick pushed a commit that referenced this pull request Jan 8, 2026
## 📝 Summary

<!--
Provide a concise summary of what this pull request is addressing.

If this PR fixes any issues, list them here by number (e.g., Fixes
#123).
-->
Similar to #7546, we also want
Plotly line charts to be reactive.

(Also see #7733)

## 🔍 Description of Changes

<!--
Detail the specific changes made in this pull request. Explain the
problem addressed and how it was resolved. If applicable, provide before
and after comparisons, screenshots, or any relevant details to help
reviewers understand the changes easily.
-->
<img width="1013" height="1006" alt="image"
src="https://github.com/user-attachments/assets/f4b7f497-c46c-4313-8dbc-a5bcff592964"
/>


## 📋 Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [ ] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] I have added tests for the changes made.
- [x] I have run the code and verified that it works as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants