Charts
Charts copied to clipboard
Fixes 4641 & 4645
The use of Swift Algorithms partitioningIndex with exact matching clause == can provide incorrect values. It has been modfied to use a >= clause as well followed by a check for an exact match from that index. This should maintain the intended behaviours and I have added a It has been modfied to use a >= clause as well followed by a check for an exact match from that index. This should maintain the intended behaviours and I have added a fix for fetching the closest X value index when the value falls between 2 indexs and uses .closest for rounding method.
Issue Link :link:
Goals :soccer:
- Replicate error in Test Suite
- Fix the bug in entriesForXValue
Implementation Details :construction:
- Fixed the usage of partitioningIndex in entriesForXValue with minimal changes.
- added support for .closest for X values in entryIndex as it seemed to be missing since the Swift Algo port.
Testing Details :mag:
ChartDataTests -> testEntriesForXValue
@danielgindi I'm surprised at the low attention this has gotten as I'd have thought this feature was pretty core to the libraries example usage.
Is it just a time issue or does this PR need to be of better quality in some way?
I can confirm this PR fixes the issues I've been encountering with markers in my line charts. It would be great to get this merged into the main branch and get an updated release out.
@Lee-Waire-Health thanks for developing the fix.
Also confirming that this fixes issues with highlighting values that I've been seeing, thanks for the PR @Lee-Waire-Health, @danielgindi would love for this to be incorporated into the main repo.
Agree @bohemima, it would be great to get this incorporated @danielgindi. Thanks for your work @Lee-Waire-Health!
One issue here is that the partitioningIndex fails when xValue to search is larger than any $0.x, it returns indexEnd. Consequently the guard statement fails and the function returns empty []. This the .closest strategy does not return the nearest entry.
The issue arrises when the data line should get drawn where the highestVisibleX value is larger than any entry.x. See #4687 for a fix of not displaying the line.
@Lee-Waire-Health Thanks for the fix, I am temporarily switching to your branch!
@Lee-Waire-Health @GinesSanchez-TopTracer could you validate that https://github.com/danielgindi/Charts/pull/4721 fixes the problem you were having here