From 32568aca40a4ffe2e079dd8cae673de9c2c2a720 Mon Sep 17 00:00:00 2001 From: Dani Arlandis Date: Mon, 8 Mar 2021 15:35:51 +0100 Subject: [PATCH] Fixed bug Tileset Histogram --- .../template/src/utils/formatter.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/template-sample-app/template/src/utils/formatter.js b/template-sample-app/template/src/utils/formatter.js index b7e38a5d..bb6ce513 100644 --- a/template-sample-app/template/src/utils/formatter.js +++ b/template-sample-app/template/src/utils/formatter.js @@ -26,10 +26,21 @@ export const currencyFormatter = (value) => { }; export const numberFormatter = (value) => { - return Intl.NumberFormat('en-US', { - maximumFractionDigits: 1, - minimumFractionDigits: 0, - notation: 'compact', - compactDisplay: 'short', - }).format(isNaN(value) ? 0 : value); + const _value = parseLogicalOperation(value); + return ( + _value.operation + + Intl.NumberFormat('en-US', { + maximumFractionDigits: 1, + minimumFractionDigits: 0, + notation: 'compact', + compactDisplay: 'short', + }).format(_value.value) + ); +}; + +const parseLogicalOperation = (value) => { + if (!isNaN(value)) return { value: value, operation: '' }; + + const _value = value.replace('>', ''); + return isNaN(_value) ? { value: 0, operation: '' } : { value: _value, operation: '> ' }; };