I have a question about CorePlot. My question is: I've drawn a curve. Next task is: curve selection. I've added the handler:
But that does not work. Any ideas? Thanks.
- (BOOL)npvCurveContainPoint:(CGPoint)point
{
if ([[graph allPlots] count] == 0) {
return NO;
}
CPTPlot* plot = [graph plotAtIndex:0];
BOOL xContains = [[plot plotRangeForCoordinate:CPTCoordinateX] containsDouble:point.x];
BOOL yContains = [[plot plotRangeForCoordinate:CPTCoordinateY] containsDouble:point.y];
if (xContains && yContains) {
return YES;
}
return NO;
}
#pragma mark - Plot Space Delegate Methods
- (BOOL)plotSpace:(CPTPlotSpace*)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point
{
CGPoint pointInPlotArea = [graph convertPoint:point fromLayer:graph.plotAreaFrame];
if ([self npvCurveContainPoint:pointInPlotArea]) {
NSLog(@"Curve is selected!!!");
}
return NO;
}