cursor.drag: Continue updating/clamping zoom box when mouse leaves chart area
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 463
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I'm using uPlot with cursor.drag enabled for both axes:
uPlot.options.cursor.drag = { x: true, y: true }
While it works as expected within the chart area, I noticed that the drag/zoom box stops updating as soon as the mouse cursor leaves the u-over / chart area.
The Goal:
I would like the zoom box to continue updating based on the mouse position, even when the cursor is outside the chart, by clamping the coordinates to the chart boundaries.
Expected Behavior:
- Horizontal Exit: If I drag to the left/right edge and then move the cursor vertically outside the chart, the zoom box should stay clamped to the horizontal boundary but continue to expand/contract vertically.
- Vertical Exit: If I drag to the top/bottom edge and then move horizontally outside, the zoom box should stay clamped vertically but continue extending horizontally.
Current Behavior:
The mousemove listener (or the internal logic) seems to stop updating the selection box once the cursor is no longer over the chart element.
Question:
Is there a native configuration or a specific hook to enable this "clamping" behavior? Or does this require a custom implementation to override the default drag logic?
uPlot Version: 1.6.32
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cursor.drag handling configured through uPlot.options.cursor.drag and the u-over chart-area mousemove path; inspect how coordinates are handled after the pointer leaves the chart. Verify horizontal and vertical boundary cases, with completion meaning the zoom box continues updating while each exited axis remains clamped to the chart boundary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100