Repository navigation
fix(plotly): support range selections on date axes - #12283
Open
kirangadhave wants to merge 3 commits into
Open
kirangadhave wants to merge 3 commits into
kirangadhave wants to merge 3 commits into
Conversation
Plotly sends date bounds as strings, but a trace can store its positions as Python dates or NumPy timestamps. Compare date-only positions at midnight so a selection keeps its time-of-day bounds. Share the range comparison across traces while preserving each trace's category and overlap rules. Refs #11653
Box and violin plots use different category orders, but their samples follow the same selection rules. Share the overlap checks so each trace only supplies its category positions. Exercise the NumPy and pure Python paths with the same boundary cases.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Timestamp precision loss causes incorrect, representation-dependent range selections, and unchecked category indexing can raise an IndexError when category and value arrays differ in length.
2 open issues
What changed in this PR
This PR addresses date-axis range selection failures in mo.ui.plotly, using shared comparisons across supported trace types.
Changes:
- Normalize date-only coordinates to midnight while retaining selection-bound times.
- Centralize range filtering for NumPy and Python backends.
- Add tests for date representations, timezones, and timestamp precision.
| File | Description |
|---|---|
| tests/_plugins/ui/_impl/test_plotly.py | Adds date-selection coverage across traces and backends. |
| marimo/_plugins/ui/_impl/plotly.py | Introduces shared axis-range handling and updates trace filtering. |
Review effort: Balanced
Keep fractional digits when parsing selection bounds and positions so exact matches agree across timestamp representations. Check the category length before reading a waterfall label in the Python fallback.
mscolnick
approved these changes
Dec 4, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

📝 Summary
Fix box selection on date axes in
mo.ui.plotly. Treat date-only coordinates as midnight and keep the time in each selection bound. Use the same comparison across traces and preserve native timestamp precision.Closes #11653
Screenshots
Before. The selection highlights the January 6 bar, but
chart.valuestays empty.After. The same selection returns the January 6 bar with
y = 2.