Skip to content

fix(plotly): support range selections on date axes - #12283

Open
kirangadhave wants to merge 3 commits into
mainfrom
kg/marimo-issue-11653-pr-check
Open

kirangadhave wants to merge 3 commits into
mainfrom
kg/marimo-issue-11653-pr-check

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

📝 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.value stays empty.

January 6 bar highlighted with an empty chart.value

After. The same selection returns the January 6 bar with y = 2.

January 6 bar highlighted and returned in chart.value

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.
@kirangadhave
kirangadhave marked this pull request as ready for review December 3, 2026 22:58
Copilot AI balanced review requested due to automatic review settings December 3, 2026 22:58
@kirangadhave kirangadhave added the bug Something isn't working label Dec 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

Comment thread marimo/_plugins/ui/_impl/plotly.py Resolved
Comment thread marimo/_plugins/ui/_impl/plotly.py Resolved
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.

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mo.ui.plotly: range selection on a bar chart with a date x-axis raises TypeError

3 participants