kaiserfarrell / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Touch drags jumps around for plotAreaFrames with padding, CPTXYPlotSpace converts points with multiple reference coordinate systems #500

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Set up a CPTXYGraph with padding in the plotAreaFrame on an iOS project:

        CPTXYGraph *barChart = ....

        barChart.paddingLeft = 0.0f;
        barChart.paddingRight = 0.0f;
        barChart.paddingTop = 0.0f;
        barChart.paddingBottom = 0.0f;

        // Padding area for axis
        barChart.plotAreaFrame.paddingLeft = 60.0f;
        barChart.plotAreaFrame.paddingBottom = 30.0f;

2. Drag around while zoomed in

What is the expected output? 
The chart follows the touches accurately while dragging

What do you see instead?
The chart jumps by (60,30) at the beginning of every drag move.

What version of the product are you using? On what operating system?
hg revision 1469 on iOS 5.1 and iOS 6.0

Please provide any additional information below.

I think this is caused by a mismatch in CPTXYPlotSpace.m:

pointingDeviceDownEvent converts the touch point like this:

    CGPoint pointInPlotArea = [self.graph convertPoint:interactionPoint toLayer:self.graph.plotAreaFrame];
    if ( [self.graph.plotAreaFrame containsPoint:pointInPlotArea] ) {
        // Handle event
        lastDragPoint = pointInPlotArea;

while pointingDeviceDraggedEvent converts the touch point like this:

    if ( isDragging ) {
        CGPoint pointInPlotArea = [self.graph convertPoint:interactionPoint toLayer:self.graph.plotAreaFrame.plotArea];
        CGPoint displacement    = CPTPointMake(pointInPlotArea.x - lastDragPoint.x, pointInPlotArea.y - lastDragPoint.y);

Note the difference between toLayer:self.graph.plotAreaFrame and 
toLayer:self.graph.plotAreaFrame.plotArea
This causes the "displacement" CGPoint to be offset with 
(barChart.plotAreaFrame.paddingLeft, barChart.plotAreaFrame.paddingBottom) for 
every touchdown.

If I change pointingDeviceDownEvent to also use 
"toLayer:self.graph.plotAreaFrame.plotArea", things seem to work nicely. (Not 
sure if that is correct, or if pointingDeviceDraggedEvent should be changed to 
"toLayer:self.graph.plotAreaFrame" instead?)

Original issue reported on code.google.com by postmes...@gmail.com on 22 Jan 2013 at 1:50

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 23 Jan 2013 at 1:51

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 23 Jan 2013 at 1:51

GoogleCodeExporter commented 8 years ago
This issue was closed by revision ac70a417bcb8.

Original comment by eskr...@mac.com on 23 Jan 2013 at 1:52

GoogleCodeExporter commented 8 years ago
Thanks, that was quick! Confirming hg rev 1470 solves the problem :)

Original comment by postmes...@gmail.com on 23 Jan 2013 at 10:08