【问题标题】:coreplot:Converted coordinates, have problems. [plotSpace plotPoint:plotPoint forPlotAreaViewPoint:point];coreplot:转换坐标,有问题。 [plotSpace plotPoint:plotPoint forPlotAreaViewPoint:point];
【发布时间】:2012-04-26 07:54:42
【问题描述】:

我想将触摸的点转换为 CPTXYPlotSpace 点。但我发现那里有与真实坐标的偏移。 我发现,它从边界计算了 x 轴的一部分。 我想将点映射到 x&y 轴的值。

我的英语很差.... 我想知道哪里错了?请告诉我。

这是代码。

-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point
{    NSDecimal plotPoint[2]; 
    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
    [plotSpace plotPoint:plotPoint forPlotAreaViewPoint:point]; 


   //HERE HAVE SOME OFFSET. I FIND ,it Calculated part of the x-axis from the border
    NSLog(@"touch plotPoint = %d, %f", 
    [[NSDecimalNumber decimalNumberWithDecimal:plotPoint[CPTCoordinateX]] intValue],
    [[NSDecimalNumber decimalNumberWithDecimal:plotPoint[CPTCoordinateY]] doubleValue]);
    return YES;
}

【问题讨论】:

    标签: iphone ios core-plot


    【解决方案1】:

    先将点转换为绘图区域的坐标系:

    CGPoint plotAreaPoint = [graph convertPoint:point toLayer:graph.plotAreaFrame.plotArea];
    [plotSpace plotPoint:plotPoint forPlotAreaViewPoint:plotAreaPoint]; 
    

    【讨论】:

    • 仅作记录,此方法在 2.0 中已弃用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多