-
Notifications
You must be signed in to change notification settings - Fork 892
Add support for reactive Plotly bar chart. #7733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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.
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev182 |
## 📝 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.
📝 Summary
Similar to #7546, we also want Plotly bar charts to be reactive
🔍 Description of Changes
I tried to stay as close as possible to how this works in Altair.
Happy to address any remarks you might have.
📋 Checklist