2012-07-24 21 views
1

我想通过点击它来绘制一个线图来获取axisLabel值?如何实现这一目标?有没有可能选择每个标签值?我已经尝试了-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point的剧情空间委托方法。因此,我只能获得绑定值。最好的解决方案是什么? 在此先感谢。如何选择标签在coreplot

+0

你想单击轴标签而不是绘制数据标签? – 2012-07-25 01:19:01

+0

嗨,Eric,如果我不清楚,请耐心等待。我的Y轴标签值为175,176,177,178 ..... with majorInterVel 5.当我按上述值之一时,我的控制台说'Point'是'NSEvent: type = LMouseDown loc =(772,203)time = 5310.5 flags = 0x100 win = 0x10022a340 winNum = 317 ctxt = 0x0 evNum = 552 click = 1 buttonNumber = 0 pressure = 1'.location每改变一次都会改变。我怎样才能得到175,176的价值......? – prakash 2012-07-25 05:11:30

+0

请给我一个解决方案... – prakash 2012-07-26 03:35:19

回答

1
  1. 从图形层的坐标系到绘图区转换点:

    CGPoint pointInPlotArea = [space.graph convertPoint:interactionPoint 
                  toLayer:space.graph.plotAreaFrame.plotArea]; 
    
  2. 转换点到数据坐标:

    NSDecimal plotPoint[2]; 
    [space plotPoint:plotPoint forPlotAreaViewPoint:pointInPlotArea]; 
    

    double plotPoint[2]; 
    [space doublePrecisionPlotPoint:plotPoint forPlotAreaViewPoint:pointInPlotArea]; 
    
+0

谢谢埃里克。它帮助了我。同样,我可以在没有触摸的情况下从绘图区域获取坐标值,只需将鼠标悬停在图表上? – prakash 2012-07-27 04:01:50

+0

如果您可以获取mouseMoved事件,则可以从事件中提取交互点并将其转换,如上所示。查看托管视图的代码,了解如何将点转换为图层的坐标。 – 2012-07-28 15:59:08