-
-
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
Highlighter fix #4721
Highlighter fix #4721
Conversation
…XValue Fixed the rounding issue of ChartDataSet.entryIndex()
@kcome Hello! Would you mind sharing some explanation on that fix? I've noticed the defect shows up only after building Charts with Xcode 13, no? |
@krzysztof-grobelny The issue #4719 happens on both Xcode 13 and 12. There are two fixes together solves #4719 : 1 is in 2 is in
Previous implementation didn't call |
@kcome Thanks for the fix, @krzysztof-grobelny This issue happens on XCode12, In the demo code for |
@liuxuan30 could we merge this PR? |
The fix is provided by the community and applied based to the following pull request: ChartsOrg#4721
The fix is provided by the community and applied based on the following pull request: ChartsOrg#4721
Hi @pmairoldi , I resolved a conflict in this PR. Could we start merge? Let me know if there is anything else need to be done. |
Think I have a proper fix open for this #4817 |
I tried with #4817 and seems to work This PR works both and seems to be expected specs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Seems to work fine.
@@ -197,9 +198,11 @@ open class ChartDataSet: ChartBaseDataSet | |||
open override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] | |||
{ | |||
let match: (ChartDataEntry) -> Bool = { $0.x == xValue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this line should be:
let match: (ChartDataEntry) -> Bool = { $0.x >= xValue }
Note the >=
instead of ==
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually nevermind, sorry for bothering you! Please disregard this and other comments - I'll delete them.
My thinking was that partitioningIndex
function requires that all values after the desired index match the expression, but after looking more carefully I see the added partition
function before running partitioningIndex
- I'm guessing the intention is to make it possible to search in non-ordered data. I'm a little worried about the performance here, but otherwise I think the implementation is correct, except one detail: comparing Doubles directly. This is probably bigger discussion about the library design, but basically due to Double representation in memory, we should never compare Doubles using the equality operator. This will break for example in a simple case: 0.3 != 0.1 + 0.2
. But as I said, that's probably a separate discussion.
chartValueNothingSelected not work |
Fixed the use of partitioningIndex(where:) in ChartDataSet.entriesForXValue
Fixed the rounding issue of ChartDataSet.entryIndex()
Issue Link 🔗
#4719
Goals ⚽
Having a working highlighter which is broken due to incorrect use of Algorithms
partitioningIndex()
Implementation Details 🚧
Partition the entries first, then call
partitioningIndex()
Testing Details 🔍
Using the attached
ChartDemo-iOS-Swift
projectOpen LineChart1 or LineChart2, tap data points, highlight should work