Skip to content

Conversation

@JCQuintas
Copy link
Member

@JCQuintas JCQuintas commented Apr 21, 2025

Resolves #16205
Fixes #16549
Fixes #16660
Fixes #17480
Supersedes #17000

Difference from the other PR

This uses @web-gestures/core to recognise the gestures. I've made the lib from scratch, thinking about extensibility and using the native event emitter api.

It should be much lighter and extensible than anything else, though it is new. So bugs might be preset 😆

As I mentioned in one of our previous meeting. It would be nice to have it as part of MUI offering if we deem it a good to have. For now it stays as a separate project.

Main change (same as last PR)

Create a interaction listener plugin. This allows us to register events directly in the SVG.

The current implementation migrates most of the interactions to the schema below.

Screenshot 2025-03-19 at 22 40 10

Other changes

  • Divided the zoom behaviours into hooks implementing the usePanOnDrag, useZoomOnPinch and useZoomOnWheel hooks
  • Make the zoom panning a bit smarter by allowing users to scroll to the edge, and once the zoom can't change anymore, it allows scrolling the page instead.

@JCQuintas JCQuintas requested a review from alexfauquette June 24, 2025 11:57
@JCQuintas JCQuintas marked this pull request as ready for review June 24, 2025 11:57
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 24, 2025
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 24, 2025
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

I will start back the review after eating, but the mobile interaction is far better on my phone with this PR 🚀

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

I played with tooltip and zoom on various charts and everything look nice 🎉👌

Comment on lines 40 to 47
const handlePanStart = () => {
startRef.current = store.value.zoom.zoomData;
};

const handlePanThrottled = rafThrottle((event: PanEvent) => {
const target = event.detail.srcEvent.target as SVGElement | undefined;
if (target?.hasAttribute('data-charts-zoom-slider') || !startRef.current) {
return;
Copy link
Member

Choose a reason for hiding this comment

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

Does adding this condition plus an handlePanEnd to clean the startRef.current would avoid the need for 'data-charts-zoom-slider'?

Suggested change
const handlePanStart = () => {
startRef.current = store.value.zoom.zoomData;
};
const handlePanThrottled = rafThrottle((event: PanEvent) => {
const target = event.detail.srcEvent.target as SVGElement | undefined;
if (target?.hasAttribute('data-charts-zoom-slider') || !startRef.current) {
return;
const handlePanStart = () => {
if(event is in drawing area){
startRef.current = store.value.zoom.zoomData;
}
};
const handlePanThrottled = rafThrottle((event: PanEvent) => {
const target = event.detail.srcEvent.target as SVGElement | undefined;
if (!startRef.current) {
return;

Copy link
Member Author

Choose a reason for hiding this comment

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

There is an issue with the releasePointerCapture of the charts cartesian axis which also uses this 'data-charts-zoom-slider'.

🤔

Maybe I can cook up something to replace it. Will look into it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've replaced it with the isElementInside check. Let me know waht you think. I can extract it from this PR so it is easier to check

Copy link
Member Author

Choose a reason for hiding this comment

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

// Clean the interaction when the mouse leaves the chart.
const moveEndHandler = instance.addInteractionListener('moveEnd', (event) => {
if (!event.detail.activeGestures.pan) {
mousePosition.current.isInChart = false;
Copy link
Member

Choose a reason for hiding this comment

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

While playing with this feature (in the radar docs), keeping track of the pointer position outside of the charts would be nice. Otherwise, it's impossible to see the bottom value (hidden by my finger).

More for a follow up PR

Copy link
Member Author

Choose a reason for hiding this comment

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

WDYM? When you move the finger to the top of the screen the tooltip moves to the bottom?

Copy link
Member

@alexfauquette alexfauquette Jun 25, 2025

Choose a reason for hiding this comment

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

If I want to see the tooltip for the Geography, the best I can do now is the second image. It would feel natural to be able to do the second. (the green potatoe represents my finger :p)

image

On desktop tooltip get remove when exiting the chart. on mobile only when finger up

Copy link
Member Author

Choose a reason for hiding this comment

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

@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 26, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 26, 2025
@JCQuintas JCQuintas merged commit 84c3d1c into mui:master Jun 27, 2025
23 checks passed
@JCQuintas JCQuintas deleted the pointer-events-manual branch June 27, 2025 13:41
@oliviertassinari oliviertassinari added the plan: Pro Impact at least one Pro user. label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

5 participants