我有一个带有线性 y 轴和对数 x 轴的散点图,所有这些都很好用。但是当我尝试将触摸点转换为绘图空间坐标时,我遇到了问题。
我在不同的地方看到了类似以下建议的内容:
- (BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(id)event atPoint:(CGPoint)point
{
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)space;
CPTScatterPlot *scatterPlot = [[[plotSpace graph] allPlots] objectAtIndex:0];
CGPoint plotAreaPoint = [[plotSpace graph] convertPoint:point toLayer:scatterPlot];
NSLog(@"PlotAreaPoint : %.1f, %.1f", plotAreaPoint.x, plotAreaPoint.y);
NSDecimal dataPoint[2];
NSDecimalNumber *xCoordinate, *yCoordinate;
[plotSpace plotPoint:dataPoint forPlotAreaViewPoint:plotAreaPoint];
xCoordinate = [NSDecimalNumber decimalNumberWithDecimal:dataPoint[0]];
yCoordinate = [NSDecimalNumber decimalNumberWithDecimal:dataPoint[1]];
NSLog(@"DataPoint : %.1f, %.1f", [xCoordinate floatValue], [yCoordinate floatValue]);
return YES;
}
当我运行它时,plotAreaPoint 似乎是正确的,yCoordinate 也是正确的。如果我在左边缘 (5.0) 或右边缘 (500.0) 点击,xCoordinate 是正确的,但如果我在中间点击,它的行为就像一个线性轴。如果我在中间点击,我得到 250.0 左右,而不是 50.0。我错过了什么,还是有其他方法可以做到这一点?
谢谢,蒂姆
最佳答案
这是一个错误。请在Core Plot issue tracker上举报.
关于objective-c - Core Plot - 如何在具有对数轴的绘图空间中将接触点转换为绘图点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10406539/