SwiftCharts
SwiftCharts copied to clipboard
Clicking on whole chart group
Recognize taps on bars works very well. The problem is when I want to click on whole group of bars - even there is half or less of full bar size. I need to recognize these taps even on very small bar. I need to know when user clicked on February group (not only grey or red bar).
I checked in DebugViewHierarchy - there is no additional views as container of group bars, so I can't recognize clicking it.
I have idea to add gesture recognizer to whole view and check if tap X position contains any bar on chart, but it will be hard to control it. Do you have any other ideas to achieve that?
Already resolved:
var touchLocationInContentView: CGPoint = recognizer.location(in: chart.contentView)
Which is location of gesture event in the chart contentView. The contentView is exactly frame that bars are located in. Then I can check if any bars is in range of gesture event tap location.