objective-c - Core Plot - 如何在具有对数轴的绘图空间中将接触点转换为绘图点

标签 objective-c ios core-plot

我有一个带有线性 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/

相关文章:

ios - 扩展 UIView 时出现 EXC_BAD_INSTRUCTION

ios - swift 中的单元测试 | IOS Storyboard |无法转换 objective-c 中定义的 View Controller 类

ios - 将免费应用程序迁移到免费增值

ios - 自定义委托(delegate)很快就为零

ios - 如何知道 visibleViewController 何时更改(Push 和 Model 两者)

iphone - 在哪里设置背景色?

iphone - 从 iPhone 中的 coreplot(散点图)中删除负轴

ios - -[NSConcreteMutableData base64EncodedStringWithOptions :]: unrecognized selector sent to instance 0x776e920'

iphone - 如何在 iOS 6 中为 UIActivityViewController 设置收件人?

objective-c - 如何将图像添加到 Core Plot CPT BarPlot 图层?