fix: Keep axis title values on the interval grid for large values - #2112
Open
a1573595 wants to merge 1 commit into
Open
fix: Keep axis title values on the interval grid for large values#2112a1573595 wants to merge 1 commit into
a1573595 wants to merge 1 commit into
Conversation
…aNNeo#1473) iterateThroughAxis accumulated axisSeek += interval, so on large values like epoch timestamps the rounding error built up and emitted artifacts such as 1698797425.999999 in place of the exact data maximum, which broke value == meta.max checks in getTitlesWidget. Values are now computed as initialValue + index * interval and snapped to max when they land on it.
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.
Description
AxisChartHelper.iterateThroughAxiswalked the axis withaxisSeek += interval. Accumulating in a loop makes the floating point error grow with every step, so on large values — epoch timestamps being the common case — the last emitted value drifts slightly off the grid. WithminX: 1698797425, maxX: 1698797426the iteration yields1698797425.999999instead of1698797426, so agetTitlesWidgetthat renders a label only whenvalue == meta.maxnever matches and the trailing title silently disappears.The loop now derives each value as
initialValue + index * interval, which keeps the error bounded instead of cumulative, and snaps to the exactmaxwhen a step lands on it (within the interval-scaled epsilon that was already used for the loop bound). Behavior for small ranges is unchanged — the existingiterateThroughAxistests pass untouched.Added a regression test that reproduces the issue's exact numbers and asserts both that the last value equals
maxand that no artifact value sits closer than half an interval to its neighbor.TestResult
Left Before, Right After
Android
iOS
Chrome
Checklist
///.example.Breaking Change?
Related Issues
Closes #1473