So Im making a graph using the Beautiful Charts Api. Im doing it in SWIFT 3. I got the graph working but now Im trying to get the selected value index, I have tried many things but they have not work. Heres my latest attempt at it.
func chartValueSelected(_ chartView: ChartViewBase, entry:
ChartDataEntry, highlight: Highlight) {
if let dataSet = chartView.data?.dataSets[ highlight.dataSetIndex] {
let Index: Int = dataSet.entryIndex( entry: entry)
print( "Selected index: \( Index)")
}
}
You can use entry.x to retrieve the x value, or isn’t that the same as the index?
print(“/(entry.x)”)