feat: CategoryBar now supports values more than 100 or less than 100 (while more than 1) #1036
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
This pull request brings the CategoryBar component to support
values
with any sum, whereas the previous one required thevalues
sum to be exactly1
or100
.By dynamically normalizing the input values to represent each category proportionally, regardless of the total, this enhancement increases flexibility and applicability in a variety of data environments. Additional unit tests ensure proper functioning in a variety of situations.
Related issue(s)
#1035
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
How has this been tested?
src/tests/vis-elements/CategoryBar.test.tsx
via jest and it passes all the tests.src/stories/vis-elements/CategoryBar.stories.tsx
and it works as expected.You may visit the following link to learn about storybook:
With Values More Than 100 (https://tremor-storybook-git-fork-lcandy2-main-tremor.vercel.app/?path=/story/visualizations-vis-categorybar--with-values-more-than-100)
With Values Less Than 100 (https://tremor-storybook-git-fork-lcandy2-main-tremor.vercel.app/?path=/story/visualizations-vis-categorybar--with-values-more-than-100)
Screenshots (if appropriate):
The screenshot values sum more than 100 (live):
The screenshot values sum less than 100 (more than 1) (live):
The PR fulfils these requirements:
main
branch