diff --git a/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.html b/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.html index 57c38b905..383a66d3b 100644 --- a/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.html +++ b/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.html @@ -36,9 +36,8 @@ @@ -55,12 +54,16 @@ - + @if (!isAggregateNan(indicator.name, indicator.weightedAvg)) { {{ @@ -93,7 +96,10 @@ {{ indicator.aggregateUnit }} } @else { - + {{ 'aggregates-component.not-applicable' | translate }} } @@ -106,14 +112,13 @@ [title]="'aggregates-component.more-information' | translate" > diff --git a/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.scss b/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.scss index 39340c50d..c5533a448 100644 --- a/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.scss +++ b/interfaces/IBF-dashboard/src/app/components/aggregates/aggregates.component.scss @@ -29,19 +29,6 @@ .aggregate-item { --inner-padding-end: 0; - .aggregate-item-thumbnail { - background: var(--ion-color-fiveten-neutral-100); - border: 0.2rem solid var(--ion-color-fiveten-neutral-100); - width: 2rem; - height: 2rem; - align-self: start; - padding: 2px; - - ion-img { - object-fit: contain; - } - } - .aggregate-item-label { line-height: 1.2; white-space: normal; @@ -50,12 +37,5 @@ } .aggregate-item-information-icon { - --inner-padding-end: 0.2rem; - cursor: pointer; - - ion-label { - margin: 0 auto; - padding-top: 0.2em; - max-width: 20px; - } + --inner-padding-end: 0; } diff --git a/interfaces/IBF-dashboard/src/app/components/disclaimer-approximate/disclaimer-approximate.component.html b/interfaces/IBF-dashboard/src/app/components/disclaimer-approximate/disclaimer-approximate.component.html index 41ded8fa0..3eab47480 100644 --- a/interfaces/IBF-dashboard/src/app/components/disclaimer-approximate/disclaimer-approximate.component.html +++ b/interfaces/IBF-dashboard/src/app/components/disclaimer-approximate/disclaimer-approximate.component.html @@ -1,4 +1,8 @@ - + 100 ? 2 : 1; + + let min = 0; + let prefix = ''; + + if (format !== NumberFormat.perc) { + // Add deviation for values between 0 and 20 + if (value > 0 && value < 20) { + prefix = '< '; + + if (value > 10) { + min = 20; + } else if (value > 0) { + min = 10; + } + } + } - value = value > 0 ? Math.max(min, value) : 0; + value = value > 0 ? Math.max(value, min) : 0; - return new Intl.NumberFormat(this.locale, { + return `${prefix}${new Intl.NumberFormat(this.locale, { maximumSignificantDigits, style, notation: 'compact', - }).format(value); + }).format(value)}`; } } diff --git a/services/API-service/src/shared/helper.service.ts b/services/API-service/src/shared/helper.service.ts index 1cea36ea1..c59f9bffd 100644 --- a/services/API-service/src/shared/helper.service.ts +++ b/services/API-service/src/shared/helper.service.ts @@ -121,21 +121,53 @@ export class HelperService { } } - public toCompactNumber( + /* + * 0 becomes 0 + * 2 becomes < 10 + * 12 becomes < 20 + * 20 becomes 20 + * 56 becomes 60 + * 297 becomes 300 + * 462 becomes 460 + * 1000 becomes 1K + * 4200 becomes 4.2K + * 225305 becomes 230K + * 79136946 becomes 79M + * negative numbers become 0 + */ + toCompactNumber( value: number, format: NumberFormat = NumberFormat.decimal0, locale = 'en-GB', ) { + if (value == null || isNaN(value)) { + return ''; + } + const style = format === NumberFormat.perc ? 'percent' : 'decimal'; - const min = format === NumberFormat.perc ? 0.1 : 10; - const maximumSignificantDigits = format === NumberFormat.perc ? 2 : 1; + const maximumSignificantDigits = value > 100 ? 2 : 1; + + let min = 0; + let prefix = ''; + + if (format !== NumberFormat.perc) { + if (value > 20) { + min = 20; + } else if (value > 0) { + min = 10; + } + + if (value > 0 && value < 20) { + prefix = '< '; + } + } - value = value > 0 ? Math.max(min, value) : 0; + value = value > 0 ? Math.max(value, min) : 0; - return new Intl.NumberFormat(locale, { + return `${prefix}${new Intl.NumberFormat(locale, { maximumSignificantDigits, style, notation: 'compact', - }).format(value); + }).format(value)}`; } }