fix: render stacked bar with stringified values#488
Merged
markov00 merged 4 commits intoelastic:masterfrom Dec 12, 2019
Merged
Conversation
The stacked bars are computed adding up the previous value with the current one. This works fine if the passed values are numbers. If the number is codified as a string, the resulting stacked value is a wrongly concatenated string of values. This commit cast every y value to a number, if NaN or null it will use null. fix elastic#487
Codecov Report
@@ Coverage Diff @@
## master #488 +/- ##
==========================================
+ Coverage 83.82% 83.85% +0.02%
==========================================
Files 158 169 +11
Lines 4724 4880 +156
Branches 961 981 +20
==========================================
+ Hits 3960 4092 +132
- Misses 749 772 +23
- Partials 15 16 +1
Continue to review full report at Codecov.
|
Collaborator
Author
|
🎉 This PR is included in version 15.0.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
4 tasks
AMoo-Miki
pushed a commit
to AMoo-Miki/OpenSearch-Dashboards
that referenced
this pull request
Feb 10, 2022
## [15.0.5](elastic/elastic-charts@v15.0.4...v15.0.5) (2019-12-12) ### Bug Fixes * render stacked bar with stringified values ([opensearch-project#488](elastic/elastic-charts#488)) ([24b9351](elastic/elastic-charts@24b9351)), closes [opensearch-project#487](elastic/elastic-charts#487)
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
In a stacked bar chart, the vertical position of each bar is computed starting from the sum of the vertical position of each previous bar. This works fine if, in the dataset, the y value is expressed as a number.
If the y value in the dataset is a string type, the chart is rendered in a weird way: the vertical position of each bar is wrongly computed as a concatenation of each y value. This PR cast every y value to a number, or to
nullif the y value is NaN ornull.It's not a good practice having a stringified number as the y value, but this gracefully render the chart also in this situation.
fix #487
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] Any consumer-facing exports were added tosrc/index.ts(and stories only import from../srcexcept for test data & storybook)[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Proper documentation or storybook story was added for features that require explanation or tutorials