Search code examples
core-plot

Pinch Zooming X and Y axes independently (Non uniformly) with Core Plot


I am using Core Plot to show graphs in my application and I want the Pinch Zooming feature to scale the X and Y axes independently. When pinch Zooming, the gesture should generate one X-pinch-component and one Y-pinch-component that should scale the axes differently.

If the user's two fingers are on a straight vertical line, the graph should only be scaled on the Y axis.

If the user's two fingers are on a straight horizontal line, the graph should only be scaled on the X axis.

If the user's two fingers are on a straight line between 01.30 and 07.30 on a Clock (45 degrees), the graph should be scaled equally on the X and Y axis - I hope you get the idea. 

How can this be achieved? Core Plot always scales my plot equally on X and Y, regardless of how the user's fingers are placed.\


Solution

  • Turn off the built-in pinch handling (allowPinchScaling = NO on the hosting view) and provide your own gesture recognizer to get the interaction information and compute the scaling angle.