| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
PatternFly-React preview: https://patternfly-react-pr-2375.surge.sh |
Sorry, something went wrong.
|
|
||
| const { props } = obj; | ||
| const { data, title = {} } = props; | ||
| const { type, percision = 0 } = title; |
There was a problem hiding this comment.
| const { type, percision = 0 } = title; | |
| const { type, precision = 0 } = title; |
Sorry, something went wrong.
There was a problem hiding this comment.
is there related issue for this PR if so can you please add it to the description
Sorry, something went wrong.
| switch (type) { | ||
| case 'percent': | ||
| primary = `${Math.round((100 * columns[iMax][1]) / sum).toString()}%`; | ||
| primary = `${((100 * columns[iMax][1]) / sum).toFixed(percision).toString()}%`; |
There was a problem hiding this comment.
Check out Intl.NumberFormat
| primary = `${((100 * columns[iMax][1]) / sum).toFixed(percision).toString()}%`; | |
| primary = `${Intl.NumberFormat(null, {style: 'percent', maximumFractionDigits: precision}).format(columns[iMax][1]) / sum)}%`; |
Sorry, something went wrong.
There was a problem hiding this comment.
Wouldn't this change the output for existing applications? Perhaps we can leave the existing code as is, unless the precision property is added?
Sorry, something went wrong.
| }} | ||
| data={donutPercentageData} | ||
| tooltip={donutConfigTooltip} | ||
| title={{ type: 'percent', percision: 1 }} |
There was a problem hiding this comment.
| title={{ type: 'percent', percision: 1 }} | |
| title={{ type: 'percent', precision: 1 }} |
Sorry, something went wrong.
There was a problem hiding this comment.
@dlabaj I think using fixed-point notation would lead to decimal places being displayed, regardless of whether the value is fractional. (e.g. If percentage is 100, precision =1 gives you 100.0%, precision = 2 gives you 100.00%, and so on).
Sorry, something went wrong.
ping @amirfefer |
Sorry, something went wrong.
| switch (type) { | ||
| case 'percent': | ||
| primary = `${Math.round((100 * columns[iMax][1]) / sum).toString()}%`; | ||
| primary = `${((100 * columns[iMax][1]) / sum).toFixed(percision).toString()}%`; |
There was a problem hiding this comment.
actually this may still be a problem - (100 * 99.99999999 / 100).toFixed(2) # => 100.00
I'm not sure if the other suggestion solves it, maybe it does
Sorry, something went wrong.
| switch (type) { | ||
| case 'percent': | ||
| primary = `${Math.round((100 * columns[iMax][1]) / sum).toString()}%`; | ||
| primary = `${((100 * columns[iMax][1]) / sum).toFixed(percision).toString()}%`; |
There was a problem hiding this comment.
Wouldn't this change the output for existing applications? Perhaps we can leave the existing code as is, unless the precision property is added?
Sorry, something went wrong.
There was a problem hiding this comment.
Agree with @dlabrecq can we require the user to use the precision property if they want this... also is there an issue related to this fix. If not can we create one and reference it.
Sorry, something went wrong.
|
I'm not sure if this is ever wanted behavior (in fact it may be seen as a bug), @amirfefer, what do you think? I'm fine with configuring through a property. |
Sorry, something went wrong.
|
@ares, toFixed apparently rounds up, so I use the known slice function. |
Sorry, something went wrong.
donut chart rounds up the title which might lead to a falsy 100%
|
ping, is there something we can do to get this merged? |
Sorry, something went wrong.
|
I see that the precision prop was added, so I'm good with that. I'd like to give @TheRealJon another chance to comment before merging. |
Sorry, something went wrong.
|
Awesome I see 2 acks now :-) |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
Sorry, something went wrong.
|
Thanks all! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
donut chart rounds up the title which might lead to a falsy 100%