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: render stacked bar with stringified values #488

Merged
merged 4 commits into from
Dec 12, 2019

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Dec 9, 2019

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 null if the y value is NaN or null.

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 strikethroughs to remove checklist items you don't feel are 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, including a check against IE11
  • [ ] 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
  • Each commit follows the convention

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
@markov00 markov00 added the bug Something isn't working label Dec 9, 2019
Copy link
Contributor

@rshen91 rshen91 left a comment

Choose a reason for hiding this comment

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

LGTM!

@codecov-io
Copy link

codecov-io commented Dec 12, 2019

Codecov Report

Merging #488 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/chart_types/xy_chart/utils/series.ts 91.37% <100%> (+0.25%) ⬆️
src/mocks/series/series.ts 81.96% <0%> (ø)
src/mocks/specs/specs.ts 76.74% <0%> (ø)
src/mocks/scale/index.ts 100% <0%> (ø)
src/mocks/index.ts 100% <0%> (ø)
src/mocks/series/index.ts 100% <0%> (ø)
src/mocks/series/seriesIdentifiers.ts 93.33% <0%> (ø)
src/mocks/scale/scale.ts 87.5% <0%> (ø)
src/mocks/utils.ts 100% <0%> (ø)
src/mocks/series/utils.ts 88.88% <0%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e049af...13b9f18. Read the comment docs.

@markov00 markov00 merged commit 811ee90 into elastic:master Dec 12, 2019
@markov00 markov00 deleted the 2019-12-07_fix-string-y-values branch December 12, 2019 16:42
markov00 pushed a commit that referenced this pull request Dec 12, 2019
## [15.0.5](v15.0.4...v15.0.5) (2019-12-12)

### Bug Fixes

* render stacked bar with stringified values ([#488](#488)) ([811ee90](811ee90)), closes [#487](#487)
@markov00
Copy link
Member Author

🎉 This PR is included in version 15.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Dec 12, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering bug with stacked data
3 participants