2017-02-03 47 views
0

我使用iOS Charts與斯威夫特3.iOS的圖表:上

chartValueSelected()確定圈位置當上我的圖上的圓圈/點用戶點擊,我想證明具有價值和彈出窗口日期。

Graph

我發現裏面chartValueSelected()點擊和展示這樣的彈出:

func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) { 
    //Set and show the popup... 
    //... 
    self.presentViewController(vc, asPopoverRelativeTo: frame, of: graph, preferredEdge: .minY, behavior: .transient) 
} 

現在我只是frame定位彈出隨意,因爲我不知道如何確定在哪裏用戶點擊。

有沒有辦法知道點擊圓的位置的x/y座標?

回答

0

啊,發現它!

委託方法返回的hightlight值有xPxyPx屬性與圓的位置有關。哇,他們真的想到這個圖庫的一切。 :)

所以我硬編碼相對這樣的偏移:

let frame = CGRect(x: highlight.xPx-36, y: highlight.yPx-15, width: 73, height: 54) 

...和它的作品: enter image description here