Microcharts icon indicating copy to clipboard operation
Microcharts copied to clipboard

[Feature] Add support for Pinch to Zoom

Open brett-estabrook opened this issue 4 years ago • 4 comments

This is a consolidation of these two issues:

  • #150
  • #80

However there is a prerequisite issue:

  • #295

The basic idea is that once we have a clip rect properly in place we can use the Skia Sharp canvas object to Translate and Scale a chart. If this transformations are coordinated with a zoom gesture this will give the look and feel of Pinch Gesture and Zooming.

Scratch Work for Scaling

Scratch Work for Gesture

Once I get a little further along with this I will make a pull request. The above works as a proof of concept in that you can pinch to zoom, however, the labels and Y axis do not properly scale. There's also some pixel precision issues with the clip rect.

Todo Items:

  • [ ] Resolve discussion points surrounding clipping on edges of chart
  • [ ] Add support for panning while zoomed in.

brett-estabrook avatar Oct 21 '21 00:10 brett-estabrook

This is functionally complete. There are however a couple issues that need to be debated. I've posted them in: https://github.com/microcharts-dotnet/Microcharts/issues/295#issuecomment-948184864

brett-estabrook avatar Oct 21 '21 01:10 brett-estabrook

I have tested this on a number of charts and all seems to work except the issues outlined in my previous comment.

https://user-images.githubusercontent.com/1433852/138197730-1cbe1b02-2610-4dc6-a895-cab46c510dd0.mp4

brett-estabrook avatar Oct 21 '21 01:10 brett-estabrook

Impressive work ! I need time to look at this

Seuleuzeuh avatar Oct 21 '21 07:10 Seuleuzeuh

I'm going to make a few changes to this a bit later. I'm going to have an option to turn on/off pinch to zoom and leave it off by default. When its off I will also disable the cliprect. This will allow backwards compatibility by default, and anyone who enables pinch to zoom can also deal with the clipping changes.

brett-estabrook avatar Oct 29 '21 23:10 brett-estabrook