gujjula / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

plotSpace avoids paddings to retrieve touch location (incl. solution) #291

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Getting point from Touch event (user clicked on a bar)
2.Using CPPlotSpace´s method "plotPoint forPlotAreaViewPoint:" to get the 
clicked x,y field

What is the expected output? What do you see instead?
A CGPoint where x is the clicked bar and y the height (both in ranges)
Instead the method avoids graph.paddingLeft -Right -Bottom -Top and 
graph.plotSpace.plotAreaFrame.paddingLeft -Right -Bottom - Top. This will alter 
the results!

What version of the product are you using? On what operating system?
CorePlot 0.3

Please provide any additional information below.

I fixed this for me (i just wand the index of clicked bar and the clicked 
height) by subtracting the paddings from the view´s touch event´s point.

point.x -= graph.paddingLeft;
point.x -= graph.plotSpace.plotAreaFrame.paddingLeft;
// the returned point now could get negative; 

point.x -= graph.paddingBottom;
point.x -= graph.plotSpace.plotAreaFrame.paddingBottom;

The plotSpace´s paddings are also accessible via 
graph.plotAreFrame.frame.origin.

If the coordinate system has a different orientation you probably need to 
remove Right and Top paddings instead.

See sample code.

Original issue reported on code.google.com by Wrede....@gmail.com on 8 Jun 2011 at 12:44

Attachments:

GoogleCodeExporter commented 9 years ago
Have you tried using the -barPlot:barWasSelectedAtRecordIndex: delegate method? 
Or do you need more information than just which bar was touched?

Original comment by eskr...@mac.com on 9 Jun 2011 at 1:39

GoogleCodeExporter commented 9 years ago
Hey, it´s the first time i read about this method (new in 0.3?). But since the 
touch event also provides information about the height, i think my post is 
still useful for some cases. 
Thanks! 

Original comment by Wrede....@gmail.com on 9 Jun 2011 at 10:45

GoogleCodeExporter commented 9 years ago

Original comment by eskr...@mac.com on 9 Jun 2011 at 12:11