fix: rounding values on stacked w percentage charts #1039
Merged
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
With stacked charts, in percentage mode, we use a default data domain of
[0,1]
instead of computing it from the stacked data.On the rendering side, we remove geometries in which the data point falls outside the computed domain.
There are cases where the stack computes function, returns floating-point errors, and in particular, with such a small interval
[0,1]
this can cause a geometry not to be rendered because the value falls, for example, right above the1
by a floating-point error. If the floating-point error falls internally on the domain, is fine, the rendering will take place and the error is barely noticeable if the error falls externally then the geometry is not rendered at all as in the example below.This PR fixes this issue, clamping the stacked as percentage values in the exact interval between 0 and 1.
The floating-point error on the computed value in the example is
1.0000000000000002
Before:
After:
Checklist
Delete any items that are not applicable to this PR.
src/index.ts
(and stories only import from../src
except for test data & storybook)