Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tap callback on bar in BarChart in iOS-Charts

I have implemented a bar chart and I would like to move to a more specific view when tapping a specific bar - just as if I tapped a UIButton. Is this possible? I need to know which bar I tapped in order to fill my other view with correct data, but I can't seem to find any way to bind an action to a specific bar in a BarChart. I'm using Swift.

like image 981
ClockWise Avatar asked Jan 27 '16 13:01

ClockWise


1 Answers

For anyone else looking for the answer it was quite straight forward. Just implement the ChartViewDelegate where you have your BarChartView and simply implement the method func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: ChartHighlight) and you're all set.

like image 168
ClockWise Avatar answered Nov 18 '22 14:11

ClockWise