Fixes markers not appearing as expected (#4645) and entriesForXValue not finding match (#4668) #4731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves Issue 4668 "entriesForXValue() not finding xValue when it should (#4668).
Resolves Issue 4645 "Markers not appearing as expected" (#4645).
The entriesForXValue function was incorrectly partiioning on ==, and also sometimes incorrectly returning an array of values that don't match at all.
The entryIndex function's switch statement assumes that the closest X value had already been found, which would often not be the case, since we are partitioning on >=.
Issue Link 🔗
#4668
#4645
Implementation Details 🚧
The entriesForXValue function was incorrectly partiioning on ==, and also sometimes incorrectly returning an array of values that don't match at all.
The entryIndex function's switch statement assumes that the closest X value had already been found, which would often not be the case, since we are partitioning on >=.
Testing Details 🔍
Tested in my own app which uses vertical bar charts, stacked vertical bars, and use annotations/markers for everything when tapped. This functionality was completely broken when I transitioned from 3.6.0 to 4.0.1. Also ran app while testing and running both the old (pre-Swift Numerics) implementation of these two functions along side the new, asserting on any differing results. Should be solid.