-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ChartViewDelegate Function func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) is not being called for every tap/touch inside the ChartView #4719
Comments
I see the same issue. The sample project is also not working! Only the middle and last data points can be selected. |
Same here, 100% accurate description of an issue and the very same observations (Charts demo app)... |
I'm experiencing the same issue with line charts. |
@PhillipMaizza @SergejLogis Downgrading the charts to 3.6.0 worked for me! |
Yeah, that helped me as well. Only I didn't downgrade the entire library to 3.6.0, but instead created a custom
|
I downgraded as well. Nice workaround though, @SergejLogis ! |
@liuxuan30 @jjatie Thanks for having a look at this PR that fixes this issue. |
@kcome I've tried your solution and it works like charm! 🥰 Much better than the one back-ported from 3.6.0. 🚀🙇♂️ |
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 |
@hrvoje0099 are you using the pull-request branch here? screen-recording-2021-10-14-at-202737_bzAFQSeK.mp4 |
I downloaded whole project (https://github.com/danielgindi/Charts) i run Demo app. |
@kcome I am facing crash in this solution. |
@faaizdaglawala I tested the demo app on simulator (xcode 13.3, iOS 15), I don't find crash after zooming and reloading chart data. |
Hi @hrvoje0099 , I did another test and found the issue you described. And actually I just fixed it in another problem I encountered so today I merged the fix. If that suites you could you have a try? (this is the commit) |
@kcome I had one chart view in which there are 2 lines in and then I reload that chart and add one line and one bar chart (CombinedChartView), now the scenario is when I zoom the chart when it is having one line and one bar chart (CombinedChartView), it works and then when I reload that chart to 2 lines then it crashes in subscript method saying index out of range The crash is in ChartData file Swift/ContiguousArrayBuffer.swift:580: Fatal error: Index out of range
This are the screenshot links of my charts |
@faaizdaglawala what you described in the comment and screenshots is probably another issue which is not related to this issue and the fix. I could reproduce a crash which is similar to your description, however the crash line is not the same as yours. Could you have a look at this #4798? |
@kcome understood your point but when I remove your changes, it starts working. |
@faaizdaglawala did you find a solution? |
@pavel-zlotarenchuk I downgraded the charts to version 3.6.0. |
interactions(FIxes ChartsOrg#4719) Changed the entriesForXValue and entryIndex method in the ChartDataSet class to resolve ChartsOrg#4719. A few things were happening, entriesForXValue was using a predicate for the partition function that would never find the value it was looking for as it is giving you the correct location in the tree to start your search and not actually searching; hence why the values are rarely selected. The prefix array method for lazy rendering views also needs a different match predicate since the partitioned array has values that wont need to be highlighted. There is another additional change I made in this PR related to the closest logic for entryIndex; prior to this change it was grabbing the next index and not the closest. Example of the incorrect closest value: xValue = 6.2 would return back closest as 7 or even 12 whichever one was directly preceding its own index, now it returns the shortest distance between x values so it can be more accurate to the users touch.
Have a fix for this 😅 ... was a debugging rodeo |
+1 |
|
@PorterHoskins What prevents you from downgrading? I import Charts from SPM; albeit my dependencies are configured in Xcode's |
Ok that worked... I was confused by the SPM support documentation in the 4.0 release. Sorry |
Closed by #4721 |
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
The text was updated successfully, but these errors were encountered: