Charts: ChartViewDelegate Function func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) is not being called for every tap/touch inside the ChartView
- I’ve read, understood, and done my best to follow the *CONTRIBUTING guidelines.
What did you do?
I upgraded the Charts(iOS) version to 4.0.1 from 3.6.0 recently. Fixed all the changes in the codebase. Everything seems to be working except for one behavior on the chart.
What did you expect to happen?
Enabled the user interaction on the chart. Added the ChartViewDelegate, and implemented the optional delegate function
public func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight)
What happened instead?
However, apparently, this delegate function public func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) is not being triggered every time when the tap inside the chart view (to be specific I was using LineChartView) is made, instead only for some places in the chart view seems to be responding to those touch events.
I am pretty, sure the delegate function used to be called without failing in Charts 3.6.0.
Additional Findings:
I tried the official demo version for iOS source codes for both 3.6.0 and 4.0.1, as I couldn’t get this issue fixed. Looks like, the demo itself is exhibiting this problem, as I could see the delegate function being called with every tap/touch in 3.6.0 but not in the demo version 4.0.1
Charts Environment
Charts version/Branch/Commit Number: 4.0.1 Xcode version: 12.5.1 Swift version: 5.4.2 Platform(s) running Charts: iOS device/simulators macOS version running Xcode: 11.5.2
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 25 (5 by maintainers)
Yeah, that helped me as well. Only I didn’t downgrade the entire library to 3.6.0, but instead created a custom
LineChartDataSetwith an overridden method:@liuxuan30 @jjatie Thanks for having a look at this PR that fixes this issue.
I downloaded whole project (https://github.com/danielgindi/Charts) i run Demo app. I added this changes from your fix in my projec:
but it didn’t solve my bug completely, the problem I wrote above remained.
What else do I need to change to make it like yours ?
This is with your fix in demo, look last bar right half: https://www.screencast.com/t/sTnLLP7x
@PhillipMaizza @SergejLogis Downgrading the charts to 3.6.0 worked for me!
This repair does not solve the problem with Bar Charts. Exactly halfway up the bar is the boundary with select. If we press in the left half we will mark that bar, but if we press in the right half or nothing will happen or it will mark the second bar on the right. Its seems that the problem is in xValue. Eg. for coordinates x = 12, y = 50 returns -0.3 for xValue. @kcome
@kcome I’ve tried your solution and it works like charm! 🥰 Much better than the one back-ported from 3.6.0. 🚀🙇♂️