0
votes

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?

1

1 Answers

3
votes

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.