Skip to content
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

fix: rounding values on stacked w percentage charts #1039

Merged

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Mar 1, 2021

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 the 1 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:
Screenshot 2021-03-01 at 14 01 08

After:
Screenshot 2021-03-01 at 14 00 44

Checklist

Delete any items that are not applicable to this PR.

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • This was checked for cross-browser compatibility
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios

Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@markov00 markov00 marked this pull request as ready for review March 1, 2021 18:26
@markov00 markov00 merged commit ee63a70 into elastic:master Mar 1, 2021
github-actions bot pushed a commit that referenced this pull request Mar 1, 2021
# [25.1.0](v25.0.1...v25.1.0) (2021-03-01)

### Bug Fixes

* rounding values on stacked w percentage charts ([#1039](#1039)) ([ee63a70](ee63a70))

### Features

* **axis:** log scale limit and base options ([#1032](#1032)) ([b38d110](b38d110))
* **partition:** clip text in partition chart fill label ([#1033](#1033)) ([be9bea0](be9bea0))
@markov00
Copy link
Member Author

markov00 commented Mar 1, 2021

🎉 This PR is included in version 25.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Mar 1, 2021
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [25.1.0](elastic/elastic-charts@v25.0.1...v25.1.0) (2021-03-01)

### Bug Fixes

* rounding values on stacked w percentage charts ([opensearch-project#1039](elastic/elastic-charts#1039)) ([021e836](elastic/elastic-charts@021e836))

### Features

* **axis:** log scale limit and base options ([#1032](elastic/elastic-charts#1032)) ([11f94c6](elastic/elastic-charts@11f94c6))
* **partition:** clip text in partition chart fill label ([opensearch-project#1033](elastic/elastic-charts#1033)) ([7626441](elastic/elastic-charts@7626441))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants