2012-07-24 24 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