2017-02-03 49 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