Skip to content

Commit

Permalink
improve digit display
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Nov 13, 2024
1 parent 2b118dc commit d13b0b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/shared/components/UI5RadialChart/UI5RadialChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const UI5RadialChart = ({
additionalInfo = '',
}) => {
const percent = max && value ? Math.round((value * 100) / max) : 0;
const text = percent + '%';
const text = (percent > 10_000 ? percent.toPrecision(3) : percent) + '%';
const textSize = size / Math.max(3.5, text.length) + 'px';

const classnames = classNames(`radial-chart`, {
Expand Down
4 changes: 3 additions & 1 deletion src/shared/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,7 @@ export function buildPathsFromObject(object, path = '') {
}

export function roundTwoDecimals(number) {
return Number(parseFloat(number).toExponential(2));
return number > 100_000
? Number.parseFloat(number).toExponential(2)
: Number.parseFloat(number).toFixed(2);
}

0 comments on commit d13b0b0

Please sign in to comment.