sag_components 1.0.554 → 1.0.556
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isNumericValue = exports.getNumberWithCommas = exports.getFormattedValue = exports.getFormattedUnits = exports.getCurrencySign = void 0;
|
|
7
7
|
const getCurrencySign = (currencyTypeToConvert, value) => {
|
|
8
8
|
if (value === undefined || value === null) {
|
|
9
|
-
return
|
|
9
|
+
return "";
|
|
10
10
|
}
|
|
11
11
|
if (isNaN(parseFloat(value))) {
|
|
12
|
-
return
|
|
12
|
+
return "";
|
|
13
13
|
}
|
|
14
|
-
if (!currencyTypeToConvert) return
|
|
15
|
-
let currencySign =
|
|
16
|
-
const currencyFormatter = new Intl.NumberFormat(
|
|
17
|
-
style:
|
|
14
|
+
if (!currencyTypeToConvert) return "";
|
|
15
|
+
let currencySign = "";
|
|
16
|
+
const currencyFormatter = new Intl.NumberFormat("en-US", {
|
|
17
|
+
style: "currency",
|
|
18
18
|
currency: currencyTypeToConvert
|
|
19
19
|
});
|
|
20
20
|
currencySign = currencyFormatter.format(Math.abs(value)).substring(0, 1);
|
|
@@ -23,21 +23,21 @@ const getCurrencySign = (currencyTypeToConvert, value) => {
|
|
|
23
23
|
exports.getCurrencySign = getCurrencySign;
|
|
24
24
|
const getFormattedUnits = num => {
|
|
25
25
|
if (num === undefined || num === null) {
|
|
26
|
-
return
|
|
26
|
+
return "";
|
|
27
27
|
}
|
|
28
28
|
if (isNaN(parseFloat(num))) {
|
|
29
|
-
return
|
|
29
|
+
return "";
|
|
30
30
|
}
|
|
31
31
|
if (Math.abs(num) >= 1000000000) {
|
|
32
|
-
return
|
|
32
|
+
return "B";
|
|
33
33
|
}
|
|
34
34
|
if (Math.abs(num) >= 1000000) {
|
|
35
|
-
return
|
|
35
|
+
return "M";
|
|
36
36
|
}
|
|
37
37
|
if (Math.abs(num) >= 1000) {
|
|
38
|
-
return
|
|
38
|
+
return "K";
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return "";
|
|
41
41
|
};
|
|
42
42
|
exports.getFormattedUnits = getFormattedUnits;
|
|
43
43
|
const getFormattedValue = num => {
|
|
@@ -48,21 +48,21 @@ const getFormattedValue = num => {
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
if (Math.abs(num) >= 1000000000) {
|
|
51
|
-
return (num / 1000000000).toFixed(1).replace(/\.0$/,
|
|
51
|
+
return (num / 1000000000).toFixed(1).replace(/\.0$/, "");
|
|
52
52
|
}
|
|
53
53
|
if (Math.abs(num) >= 1000000) {
|
|
54
|
-
return (num / 1000000).toFixed(1).replace(/\.0$/,
|
|
54
|
+
return (num / 1000000).toFixed(1).replace(/\.0$/, "");
|
|
55
55
|
}
|
|
56
56
|
if (Math.abs(num) >= 1000) {
|
|
57
|
-
return (num / 1000).toFixed(1).replace(/\.0$/,
|
|
57
|
+
return (num / 1000).toFixed(1).replace(/\.0$/, "");
|
|
58
58
|
}
|
|
59
|
-
return num
|
|
59
|
+
return num;
|
|
60
60
|
};
|
|
61
61
|
exports.getFormattedValue = getFormattedValue;
|
|
62
62
|
const getNumberWithCommas = x => {
|
|
63
63
|
let param = x.toString();
|
|
64
64
|
const pattern = /(-?\d+)(\d{3})/;
|
|
65
|
-
while (pattern.test(param)) param = param.replace(pattern,
|
|
65
|
+
while (pattern.test(param)) param = param.replace(pattern, "$1,$2");
|
|
66
66
|
return param;
|
|
67
67
|
};
|
|
68
68
|
exports.getNumberWithCommas = getNumberWithCommas;
|
|
@@ -34,7 +34,17 @@ const TotalDoughnutChart = props => {
|
|
|
34
34
|
const [DoughnutChartRadius, setDoughnutChartRadius] = (0, _react.useState)(0);
|
|
35
35
|
const [zoomResolution, setZoomResolution] = (0, _react.useState)(1);
|
|
36
36
|
const DoughnutChartContainerRef = (0, _react.useRef)();
|
|
37
|
-
const dotCutTrenty = row =>
|
|
37
|
+
const dotCutTrenty = row => {
|
|
38
|
+
if (!row || !row.value) return 0;
|
|
39
|
+
let value = 0;
|
|
40
|
+
if (row !== null && row !== void 0 && row.value && Math.abs(row.value) > 0 && row.value % 1 != 0) {
|
|
41
|
+
var _row$value;
|
|
42
|
+
value = row === null || row === void 0 ? void 0 : (_row$value = row.value) === null || _row$value === void 0 ? void 0 : _row$value.toFixed(2);
|
|
43
|
+
} else {
|
|
44
|
+
value = row === null || row === void 0 ? void 0 : row.value;
|
|
45
|
+
}
|
|
46
|
+
return dotCut ? (0, _CommonFunctions.getFormattedValue)(value) : (0, _CommonFunctions.getNumberWithCommas)(value);
|
|
47
|
+
};
|
|
38
48
|
(0, _react.useEffect)(() => {
|
|
39
49
|
const handleResize = () => {
|
|
40
50
|
setZoomResolution(window.devicePixelRatio);
|
|
@@ -101,7 +111,7 @@ const TotalDoughnutChart = props => {
|
|
|
101
111
|
width: width
|
|
102
112
|
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.CurrencySign, {
|
|
103
113
|
id: "CurrencySign"
|
|
104
|
-
}, currencySign ? (0, _CommonFunctions.getCurrencySign)(currencyType, value) : ""), dotCut ? (0, _CommonFunctions.getFormattedValue)(value) : (0, _CommonFunctions.getNumberWithCommas)(value), dotCut ? (0, _CommonFunctions.getFormattedUnits)(value) : ""), addingBenchmark && /*#__PURE__*/_react.default.createElement(_Benchmark.Benchmark, null))), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.DoughnutChartAndLegendContainer, {
|
|
114
|
+
}, currencySign ? (0, _CommonFunctions.getCurrencySign)(currencyType, value) : ""), dotCut ? (0, _CommonFunctions.getFormattedValue)(value && Math.abs(value) > 0 && value % 1 != 0 ? value === null || value === void 0 ? void 0 : value.toFixed(2) : value) : (0, _CommonFunctions.getNumberWithCommas)(value), dotCut ? (0, _CommonFunctions.getFormattedUnits)(value) : ""), addingBenchmark && /*#__PURE__*/_react.default.createElement(_Benchmark.Benchmark, null))), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.DoughnutChartAndLegendContainer, {
|
|
105
115
|
id: "DoughnutChartAndLegendContainer"
|
|
106
116
|
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.DoughnutChartContainer, {
|
|
107
117
|
id: "DoughnutChartContainer",
|