Take the 2-minute tour ×

I have to add one plot symbol and display x and y coordinate values at the point selected by the user. And the task was implemented by adding CPTPlotSpaceAnnotation in the method

-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index 

and returning nil value at index other than the selected one in the method,

 -(CPTPlotSymbol *)symbolForScatterPlot:(GraphScatterPlot *)plot recordIndex:(NSUInteger)index 

for displaying only one plot.

For displaying only one plot I have to reload the graph for each user touch on the line. But it is a tedious process in case of large data sets. So the UI got stucked for a while after each touch. How can I avoid this?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Instead of drawing the plot symbols on the main scatter plot, use a second scatter plot for that. It only needs one data point--the one you want marked. Call -reloadData on the second plot only (not on the graph) when you want to update the position of the symbol. Return zero (0) from -numberOfRecordsForPlot: to remove the plot symbol. If you do it this way, you won't need the -symbolForScatterPlot:recordIndex: datasource method, either. Just set the plotSymbol on the main plot to nil (the default) and to the desired marker on the second plot.

share|improve this answer
Thank you. It works good. :) –  Arya Feb 9 '12 at 6:46
add comment

Your Answer


