简体   繁体   中英

Core plot ios user interaction

I am using core plot to display a line graph in my iphone app but I want to allow user interaction in this graph. By user interaction I mean when a user touches a spot on the graph it should display the corresponding x and y values. This is similar to the what I am looking for -

在此处输入图片说明

Can some one please link me to some tutorial on how to do this or show some code on how to do it. Thanks

You can use a second scatter plot and an annotation to display the selection line and label. The "Selection Demo" in the Mac version of the CPTTestApp example app shows one way to do this. The demo limits the selection to data points on the plot. If you want to respond to touches anywhere in the plot area, implement the -plotSpace:shouldHandlePointingDeviceXXXXEvent:atPoint: plot space delegate methods to control the selection line. Use the plot space to convert the given point to your data coordinates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM