fix(LineChart): correct PointMode valueIndex and dot alignment#173
Open
saadkhalidkhan wants to merge 2 commits into
Open
fix(LineChart): correct PointMode valueIndex and dot alignment#173saadkhalidkhan wants to merge 2 commits into
saadkhalidkhan wants to merge 2 commits into
Conversation
Replace indexOfFirst lookup that biased toward the next index due to floating-point rounding. Find the nearest xPositions entry within the PointMode threshold and snap popups to the exact data point value.
Use the same x coordinates as the line path when drawing dots so marker positions stay consistent with large datasets and view ranges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
valueIndexinPopupProperties.Mode.PointModefor large datasets (reported with 30 data points)indexOfFirst { x >= xPosition }with nearest-neighbor lookup onpathData.xPositionsto avoid off-by-one errors from floating-point roundingxPositionsfor consistent marker placementFixes #129
Root cause
calculateValueIndexmapped touch position usingindexOfFirst { x >= xPosition }against path bounds width. Small floating-point differences pushed the index to the next data point (e.g. index 4 instead of 3). PointMode also reused interpolated popup values instead of the tapped point.Commits
fix(LineChart): correct PointMode valueIndex with nearest data pointfix(LineChart): align dot x positions with line path xPositionsTest plan
:compose-charts:compileDebugKotlinAndroidbuilds successfully:app:compileDebugKotlinAndroidbuilds successfullyPopupProperties.Mode.PointMode()— tap each dot,valueIndexmatches label indexMode.Normal— behavior unchanged