logitude-dashboard-library 3.2.63 → 3.2.65
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.
- package/dist/Utils/DateHelper.d.ts +1 -1
- package/dist/assets/styles/dl-dashboard.scss +11 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/KpiChart.d.ts +1 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/PivotAgGridSupport.d.ts +13 -0
- package/dist/index.js +769 -400
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +769 -400
- package/dist/index.modern.js.map +1 -1
- package/dist/styles/dl-dashboard.scss +11 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -597,7 +597,103 @@ var getLast30DaysDates = function getLast30DaysDates(format) {
|
|
|
597
597
|
return dateValues;
|
|
598
598
|
};
|
|
599
599
|
|
|
600
|
-
var
|
|
600
|
+
var getDateRangesByPeriod = function getDateRangesByPeriod(_operator, _interval, _range, _format) {
|
|
601
|
+
if (_format === void 0) {
|
|
602
|
+
_format = "YYYYMMDD000000";
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
if (!_operator || !_interval || !_range) return null;
|
|
606
|
+
var result = {
|
|
607
|
+
date1: null,
|
|
608
|
+
date2: null
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
if (_operator.toLowerCase() == 'current') {
|
|
612
|
+
switch (_range) {
|
|
613
|
+
case "Day":
|
|
614
|
+
result.date1 = getTodayDates()[0];
|
|
615
|
+
result.date2 = getTodayDates()[1];
|
|
616
|
+
break;
|
|
617
|
+
|
|
618
|
+
case "Week":
|
|
619
|
+
result.date1 = getCurrentWeekDates()[0];
|
|
620
|
+
result.date2 = getCurrentWeekDates()[1];
|
|
621
|
+
break;
|
|
622
|
+
|
|
623
|
+
case "Month":
|
|
624
|
+
result.date1 = getCurrentMonthDates()[0];
|
|
625
|
+
result.date2 = getCurrentMonthDates()[1];
|
|
626
|
+
break;
|
|
627
|
+
|
|
628
|
+
case "Current_Month_To_Date":
|
|
629
|
+
case "Month To Date":
|
|
630
|
+
result.date1 = getCurrentMonthToDateDates()[0];
|
|
631
|
+
result.date2 = getCurrentMonthToDateDates()[1];
|
|
632
|
+
break;
|
|
633
|
+
|
|
634
|
+
case "Quarter":
|
|
635
|
+
result.date1 = getCurrentQuarterDates()[0];
|
|
636
|
+
result.date2 = getCurrentQuarterDates()[1];
|
|
637
|
+
break;
|
|
638
|
+
|
|
639
|
+
case "Current_Quarter_To_Date":
|
|
640
|
+
case "Quarter To Date":
|
|
641
|
+
result.date1 = getCurrentQuarterToDateDates()[0];
|
|
642
|
+
result.date2 = getCurrentQuarterToDateDates()[1];
|
|
643
|
+
break;
|
|
644
|
+
|
|
645
|
+
case "Year":
|
|
646
|
+
result.date1 = getCurrentYearDates()[0];
|
|
647
|
+
result.date2 = getCurrentYearDates()[1];
|
|
648
|
+
break;
|
|
649
|
+
|
|
650
|
+
case "Current_Year_To_Date":
|
|
651
|
+
case "Year To Date":
|
|
652
|
+
result.date1 = getCurrentYearToDateDates()[0];
|
|
653
|
+
result.date2 = getCurrentYearToDateDates()[1];
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
} else {
|
|
657
|
+
var dateGroupCodes = {
|
|
658
|
+
'Day': 'days',
|
|
659
|
+
'Week': 'weeks',
|
|
660
|
+
'Month': 'months',
|
|
661
|
+
'Quarter': 'quarters',
|
|
662
|
+
'Year': 'years',
|
|
663
|
+
'Year To Date': 'years',
|
|
664
|
+
'Quarter To Date': 'quarters',
|
|
665
|
+
'Month To Date': 'months'
|
|
666
|
+
};
|
|
667
|
+
var customDateGroupCodes = ['Year To Date', 'Quarter To Date', 'Month To Date'];
|
|
668
|
+
|
|
669
|
+
if (_operator.toLowerCase() == 'next') {
|
|
670
|
+
result.date1 = moment().startOf(dateGroupCodes[_range]).add(1, dateGroupCodes[_range]).format(_format);
|
|
671
|
+
result.date2 = moment().startOf(dateGroupCodes[_range]).add(Number(_interval), dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
|
|
672
|
+
} else if (_operator.toLowerCase() == 'previous' && !customDateGroupCodes.includes(_range)) {
|
|
673
|
+
result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
|
|
674
|
+
result.date2 = moment().subtract(1, dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
|
|
675
|
+
} else if (_operator.toLowerCase() == 'previous' && customDateGroupCodes.includes(_range)) {
|
|
676
|
+
result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
|
|
677
|
+
result.date2 = moment().format(_format);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return result;
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate, _operator, _interval, _range) {
|
|
685
|
+
if (_operator === void 0) {
|
|
686
|
+
_operator = null;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (_interval === void 0) {
|
|
690
|
+
_interval = null;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (_range === void 0) {
|
|
694
|
+
_range = null;
|
|
695
|
+
}
|
|
696
|
+
|
|
601
697
|
var result = {
|
|
602
698
|
fromDate: null,
|
|
603
699
|
toDate: null
|
|
@@ -705,6 +801,12 @@ var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate)
|
|
|
705
801
|
result.fromDate = getCurrentWeekDates()[0];
|
|
706
802
|
result.toDate = getCurrentWeekDates()[1];
|
|
707
803
|
break;
|
|
804
|
+
|
|
805
|
+
case "Previous_Next":
|
|
806
|
+
var previousNextDates = getDateRangesByPeriod(_operator || "", _interval || "", _range || "");
|
|
807
|
+
result.fromDate = previousNextDates && previousNextDates.date1 ? previousNextDates.date1 : null;
|
|
808
|
+
result.toDate = previousNextDates && previousNextDates.date2 ? previousNextDates.date2 : null;
|
|
809
|
+
break;
|
|
708
810
|
}
|
|
709
811
|
|
|
710
812
|
return result;
|
|
@@ -1103,11 +1205,18 @@ var KpiChart = function KpiChart(props) {
|
|
|
1103
1205
|
|
|
1104
1206
|
if (isKPISettingsActivated) {
|
|
1105
1207
|
var PeriodDateFilterDates = getDateRangesByCode(kpiSettings.PeriodDateFilter.DateTimeValueCode, null, null);
|
|
1106
|
-
var
|
|
1208
|
+
var comparePeriodOperator = kpiSettings.ComparePeriodDateFilter.DateRangeOperator || kpiSettings.ComparePeriodDateFilter.Operator;
|
|
1209
|
+
var comparePeriodInterval = kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue != null ? String(kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue) : null;
|
|
1210
|
+
var ComparePeriodDateFilterDates = kpiSettings.ComparisonPeriodType == 'Manually' ? getDateRangesByCode(kpiSettings.ComparePeriodDateFilter.DateTimeValueCode, kpiSettings.ComparePeriodDateFilter.FieldValue, kpiSettings.ComparePeriodDateFilter.FieldValue2, comparePeriodOperator, comparePeriodInterval, kpiSettings.ComparePeriodDateFilter.DateGroupCode) : getDateRangesByCode(null, null, null);
|
|
1107
1211
|
kpiSettings.PeriodDateFilter.FieldValue = PeriodDateFilterDates.fromDate;
|
|
1108
1212
|
kpiSettings.PeriodDateFilter.FieldValue2 = PeriodDateFilterDates.toDate;
|
|
1109
1213
|
kpiSettings.ComparePeriodDateFilter.FieldValue = ComparePeriodDateFilterDates.fromDate;
|
|
1110
1214
|
kpiSettings.ComparePeriodDateFilter.FieldValue2 = ComparePeriodDateFilterDates.toDate;
|
|
1215
|
+
|
|
1216
|
+
if (kpiSettings.ComparisonPeriodType == 'Manually' && kpiSettings.ComparePeriodDateFilter.DateTimeValueCode == 'Previous_Next') {
|
|
1217
|
+
kpiSettings.ComparePeriodDateFilter.Operator = 'Between';
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1111
1220
|
_updatedWidget.KPIComparisonSettings = JSON.stringify(kpiSettings);
|
|
1112
1221
|
}
|
|
1113
1222
|
|
|
@@ -2041,373 +2150,194 @@ var TableChart = function TableChart(props) {
|
|
|
2041
2150
|
}));
|
|
2042
2151
|
};
|
|
2043
2152
|
|
|
2044
|
-
var
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2153
|
+
var PIVOT_DATE_DATA_CELL_CLASS = 'dl-pivot-date-data-cell';
|
|
2154
|
+
var getPivotDataCellClassNames = function getPivotDataCellClassNames(measure) {
|
|
2155
|
+
if (isPivotDateMinMaxMeasure(measure)) {
|
|
2156
|
+
return "dl-ag-pivot-data-cell " + PIVOT_DATE_DATA_CELL_CLASS;
|
|
2157
|
+
}
|
|
2048
2158
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2159
|
+
return 'dl-ag-pivot-data-cell';
|
|
2160
|
+
};
|
|
2161
|
+
var isPivotDateMinMaxMeasure = function isPivotDateMinMaxMeasure(measure) {
|
|
2162
|
+
if (!measure) return false;
|
|
2163
|
+
if (measure.MeasureCode !== 'Min' && measure.MeasureCode !== 'Max') return false;
|
|
2164
|
+
return FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
2165
|
+
};
|
|
2052
2166
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
var
|
|
2167
|
+
var toValidDate = function toValidDate(value) {
|
|
2168
|
+
if (isPivotMeasureValueEmpty(value)) return null;
|
|
2169
|
+
var date = moment(value);
|
|
2170
|
+
if (!date || !date.isValid()) return null;
|
|
2171
|
+
return date.toDate();
|
|
2172
|
+
};
|
|
2056
2173
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2174
|
+
var formatPivotDateMeasureValue = function formatPivotDateMeasureValue(value) {
|
|
2175
|
+
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2176
|
+
var date = moment(value);
|
|
2177
|
+
if (!date || !date.isValid()) return '';
|
|
2178
|
+
return date.format('DD.MM.YYYY');
|
|
2179
|
+
};
|
|
2180
|
+
var isRowPivotField = function isRowPivotField(field) {
|
|
2181
|
+
return !!(field.PivotCode && field.PivotCode.indexOf('Row') !== -1);
|
|
2182
|
+
};
|
|
2183
|
+
var truncateToTwoDecimals = function truncateToTwoDecimals(value) {
|
|
2184
|
+
var numericValue = isNullOrUndefinedOrEmpty(value) ? 0 : Number(value);
|
|
2185
|
+
var safeValue = isNaN(numericValue) ? 0 : numericValue;
|
|
2186
|
+
var decimalParts = safeValue.toString().split('.');
|
|
2187
|
+
var firstPart = decimalParts[0] ? decimalParts[0] : '0';
|
|
2188
|
+
var secondPart = decimalParts[1] ? decimalParts[1].toString().substr(0, 2) : '0';
|
|
2189
|
+
return Number(firstPart + '.' + secondPart);
|
|
2190
|
+
};
|
|
2191
|
+
var isPivotMeasureValueEmpty = function isPivotMeasureValueEmpty(value) {
|
|
2192
|
+
return value === null || value === undefined || value === '';
|
|
2193
|
+
};
|
|
2194
|
+
var logitudeSumAgg = function logitudeSumAgg(params) {
|
|
2195
|
+
var values = params && params.values ? params.values : [];
|
|
2196
|
+
if (values.length === 0) return null;
|
|
2197
|
+
var total = 0;
|
|
2198
|
+
var hasValue = false;
|
|
2063
2199
|
|
|
2064
|
-
|
|
2065
|
-
|
|
2200
|
+
for (var i = 0; i < values.length; i++) {
|
|
2201
|
+
if (isPivotMeasureValueEmpty(values[i])) continue;
|
|
2202
|
+
hasValue = true;
|
|
2203
|
+
total += truncateToTwoDecimals(values[i]);
|
|
2204
|
+
}
|
|
2066
2205
|
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
widgetRefData.current = props.customChartProps.widget;
|
|
2070
|
-
getPivotTableData();
|
|
2071
|
-
}
|
|
2206
|
+
return hasValue ? total : null;
|
|
2207
|
+
};
|
|
2072
2208
|
|
|
2073
|
-
|
|
2074
|
-
|
|
2209
|
+
var isAgGridDateMeasureTotalAggregation = function isAgGridDateMeasureTotalAggregation(params) {
|
|
2210
|
+
var aggParams = params;
|
|
2211
|
+
var rowNode = aggParams.rowNode;
|
|
2075
2212
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
document.addEventListener("resizeStop", handleResize);
|
|
2080
|
-
return function () {
|
|
2081
|
-
document.removeEventListener("resizeStop", handleResize);
|
|
2082
|
-
};
|
|
2083
|
-
}, []);
|
|
2084
|
-
React.useEffect(function () {
|
|
2085
|
-
if (props.customChartProps.isInEditMode) {
|
|
2086
|
-
var _pivotGridRef$current;
|
|
2213
|
+
if (rowNode && rowNode.footer) {
|
|
2214
|
+
return true;
|
|
2215
|
+
}
|
|
2087
2216
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2217
|
+
if (rowNode && rowNode.group && rowNode.leafGroup === false) {
|
|
2218
|
+
return true;
|
|
2219
|
+
}
|
|
2091
2220
|
|
|
2092
|
-
|
|
2093
|
-
var _pivotGridRef$current2;
|
|
2221
|
+
var colDef = aggParams.colDef || aggParams.column && aggParams.column.getColDef && aggParams.column.getColDef();
|
|
2094
2222
|
|
|
2095
|
-
|
|
2223
|
+
if (!colDef) {
|
|
2224
|
+
return false;
|
|
2225
|
+
}
|
|
2096
2226
|
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
}, 5);
|
|
2101
|
-
}
|
|
2102
|
-
}, [props.customChartProps.isInEditMode]);
|
|
2227
|
+
if (colDef.pivotTotalColumnIds !== undefined && colDef.pivotTotalColumnIds !== null) {
|
|
2228
|
+
return true;
|
|
2229
|
+
}
|
|
2103
2230
|
|
|
2104
|
-
var
|
|
2105
|
-
|
|
2231
|
+
var colId = colDef.colId || aggParams.column && aggParams.column.getColId && aggParams.column.getColId();
|
|
2232
|
+
return !!(colId && String(colId).indexOf('PivotRowTotal_') === 0);
|
|
2233
|
+
};
|
|
2106
2234
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2235
|
+
var isDevExtremePivotDataCellTotalOrGrandTotal = function isDevExtremePivotDataCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields) {
|
|
2236
|
+
if (!cell) {
|
|
2237
|
+
return false;
|
|
2238
|
+
}
|
|
2109
2239
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}
|
|
2240
|
+
if (hasRowFields && (cell.rowType === 'T' || cell.rowType === 'GT')) {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2113
2243
|
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
setIsLoading(false);
|
|
2118
|
-
return;
|
|
2119
|
-
}
|
|
2244
|
+
if (hasColumnFields && (cell.columnType === 'T' || cell.columnType === 'GT')) {
|
|
2245
|
+
return true;
|
|
2246
|
+
}
|
|
2120
2247
|
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
widgetLoadLogger.log(res);
|
|
2128
|
-
})["catch"](function (err) {
|
|
2129
|
-
console.log("Error while Getting Pivot Table Data: ", err);
|
|
2130
|
-
tabledata.current = null;
|
|
2131
|
-
setPivotDataSourceFields();
|
|
2132
|
-
setIsLoading(false);
|
|
2133
|
-
});
|
|
2134
|
-
};
|
|
2248
|
+
return false;
|
|
2249
|
+
};
|
|
2250
|
+
var isDevExtremeSummaryCellTotalOrGrandTotal = function isDevExtremeSummaryCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields) {
|
|
2251
|
+
if (!cell) {
|
|
2252
|
+
return false;
|
|
2253
|
+
}
|
|
2135
2254
|
|
|
2136
|
-
var
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
e.cellElement.children[0].style.backgroundColor = "#f4433673";
|
|
2141
|
-
}
|
|
2255
|
+
var rowPath = cell._rowPath;
|
|
2256
|
+
var columnPath = cell._columnPath;
|
|
2257
|
+
var rowType = rowPath && rowPath[0] ? rowPath[0].type : null;
|
|
2258
|
+
var columnType = columnPath && columnPath[0] ? columnPath[0].type : null;
|
|
2142
2259
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
e.cellElement.children[0].style.backgroundColor = "#03a9f4ad";
|
|
2147
|
-
}
|
|
2148
|
-
}, []);
|
|
2149
|
-
var onCellClick = React.useCallback(function (e) {
|
|
2150
|
-
if (e.area === 'data') {
|
|
2151
|
-
var pivotFields = [];
|
|
2152
|
-
e.columnFields.forEach(function (c, index) {
|
|
2153
|
-
var fieldValue = e.cell.columnPath[index];
|
|
2260
|
+
if (hasRowFields && (rowType === 'T' || rowType === 'GT')) {
|
|
2261
|
+
return true;
|
|
2262
|
+
}
|
|
2154
2263
|
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
}));
|
|
2159
|
-
}
|
|
2160
|
-
});
|
|
2161
|
-
e.rowFields.forEach(function (r, index) {
|
|
2162
|
-
var fieldValue = e.cell.rowPath[index];
|
|
2264
|
+
if (hasColumnFields && (columnType === 'T' || columnType === 'GT')) {
|
|
2265
|
+
return true;
|
|
2266
|
+
}
|
|
2163
2267
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
});
|
|
2170
|
-
props.customChartProps.onSelectDataPoint({
|
|
2171
|
-
MeasureFieldId: '',
|
|
2172
|
-
Widget: props.customChartProps.widget,
|
|
2173
|
-
MeasureCode: '',
|
|
2174
|
-
Formula: '',
|
|
2175
|
-
GroupById: '',
|
|
2176
|
-
PivotFields: pivotFields
|
|
2177
|
-
});
|
|
2178
|
-
}
|
|
2179
|
-
}, []);
|
|
2268
|
+
return false;
|
|
2269
|
+
};
|
|
2270
|
+
var isAgGridPivotDateMeasureTotalDisplayCell = function isAgGridPivotDateMeasureTotalDisplayCell(params) {
|
|
2271
|
+
var node = params && params.node;
|
|
2272
|
+
var colDef = params && params.colDef;
|
|
2180
2273
|
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
});
|
|
2185
|
-
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2186
|
-
};
|
|
2274
|
+
if (node && node.footer) {
|
|
2275
|
+
return true;
|
|
2276
|
+
}
|
|
2187
2277
|
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
var bValue = b.value == null ? -1 : Number(b.value);
|
|
2278
|
+
if (node && node.group && node.leafGroup === false) {
|
|
2279
|
+
return true;
|
|
2280
|
+
}
|
|
2192
2281
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2282
|
+
if (!colDef) {
|
|
2283
|
+
return false;
|
|
2284
|
+
}
|
|
2196
2285
|
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2286
|
+
if (colDef.pivotTotalColumnIds !== undefined && colDef.pivotTotalColumnIds !== null) {
|
|
2287
|
+
return true;
|
|
2288
|
+
}
|
|
2200
2289
|
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2290
|
+
return isPivotRowGrandTotalColumnDef(colDef);
|
|
2291
|
+
};
|
|
2292
|
+
var logitudeMinAgg = function logitudeMinAgg(params) {
|
|
2293
|
+
if (isAgGridDateMeasureTotalAggregation(params)) {
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2204
2296
|
|
|
2205
|
-
|
|
2297
|
+
var values = params && params.values ? params.values : [];
|
|
2298
|
+
var minDate = null;
|
|
2299
|
+
var minValue = null;
|
|
2206
2300
|
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2301
|
+
for (var i = 0; i < values.length; i++) {
|
|
2302
|
+
var currentDate = toValidDate(values[i]);
|
|
2303
|
+
if (!currentDate) continue;
|
|
2210
2304
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2305
|
+
if (!minDate || currentDate.getTime() < minDate.getTime()) {
|
|
2306
|
+
minDate = currentDate;
|
|
2307
|
+
minValue = values[i];
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2214
2310
|
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2311
|
+
return minValue;
|
|
2312
|
+
};
|
|
2313
|
+
var logitudeMaxAgg = function logitudeMaxAgg(params) {
|
|
2314
|
+
if (isAgGridDateMeasureTotalAggregation(params)) {
|
|
2315
|
+
return null;
|
|
2316
|
+
}
|
|
2219
2317
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2318
|
+
var values = params && params.values ? params.values : [];
|
|
2319
|
+
var maxDate = null;
|
|
2320
|
+
var maxValue = null;
|
|
2223
2321
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2322
|
+
for (var i = 0; i < values.length; i++) {
|
|
2323
|
+
var currentDate = toValidDate(values[i]);
|
|
2324
|
+
if (!currentDate) continue;
|
|
2227
2325
|
|
|
2228
|
-
|
|
2326
|
+
if (!maxDate || currentDate.getTime() > maxDate.getTime()) {
|
|
2327
|
+
maxDate = currentDate;
|
|
2328
|
+
maxValue = values[i];
|
|
2229
2329
|
}
|
|
2230
|
-
};
|
|
2231
|
-
|
|
2232
|
-
var setPivotDataSourceFields = function setPivotDataSourceFields() {
|
|
2233
|
-
if (tabledata.current && tabledata.current.PivoFields && tabledata.current.PivotMeasures) {
|
|
2234
|
-
var pivotRowsAndColumnsFields = tabledata.current.PivoFields.map(function (field) {
|
|
2235
|
-
return {
|
|
2236
|
-
dataField: field.PivotCode,
|
|
2237
|
-
caption: field.DisplayName,
|
|
2238
|
-
name: field.PivotName,
|
|
2239
|
-
width: 100,
|
|
2240
|
-
allowSorting: false,
|
|
2241
|
-
allowFiltering: false,
|
|
2242
|
-
area: field.PivotCode && field.PivotCode.includes('Row') ? 'row' : 'column',
|
|
2243
|
-
sortingMethod: function sortingMethod(a, b) {
|
|
2244
|
-
return SortRowAndColumnHeaders(a, b, field);
|
|
2245
|
-
},
|
|
2246
|
-
expanded: true,
|
|
2247
|
-
wordWrapEnabled: true,
|
|
2248
|
-
fieldData: {
|
|
2249
|
-
FieldId: field.FieldId,
|
|
2250
|
-
FieldType: field.FieldType ? field.FieldType : "Field",
|
|
2251
|
-
FieldValue: '',
|
|
2252
|
-
DateCode: field.DateCode
|
|
2253
|
-
},
|
|
2254
|
-
customizeText: function customizeText(cellInfo) {
|
|
2255
|
-
return getColumnNameByColumnId(field.PivotName, field.PivotCode, cellInfo.value);
|
|
2256
|
-
}
|
|
2257
|
-
};
|
|
2258
|
-
});
|
|
2259
|
-
var pivotDataCellsFields = tabledata.current.PivotMeasures.map(function (measure) {
|
|
2260
|
-
return {
|
|
2261
|
-
dataField: measure.PivotMeasureCode,
|
|
2262
|
-
area: 'data',
|
|
2263
|
-
dataType: 'number',
|
|
2264
|
-
wordWrapEnabled: true,
|
|
2265
|
-
caption: measure.MeasureCode == 'Sum' && typeof measure.DisplayName == 'string' ? ConvertStringToPascalCaseHelper(measure.DisplayName.replace("Sum of ", "")) : ConvertStringToPascalCaseHelper(measure.DisplayName),
|
|
2266
|
-
summaryType: 'custom',
|
|
2267
|
-
calculateCustomSummary: function calculateCustomSummary(options) {
|
|
2268
|
-
if (options.summaryProcess == 'calculate') {
|
|
2269
|
-
var _value = !isNullOrUndefinedOrEmpty(options.value) ? options.value : 0;
|
|
2270
|
-
|
|
2271
|
-
var decimalParts = _value.toString().split(".");
|
|
2272
|
-
|
|
2273
|
-
var firstPart = decimalParts[0] ? decimalParts[0] : 0;
|
|
2274
|
-
var secondPart = decimalParts[1] ? decimalParts[1] : 0;
|
|
2275
|
-
secondPart = secondPart.toString().substr(0, 2);
|
|
2276
|
-
|
|
2277
|
-
var _finalVal = firstPart + "." + secondPart;
|
|
2278
|
-
|
|
2279
|
-
options.value = Number(_finalVal);
|
|
2280
|
-
options.totalValue = (!isNullOrUndefinedOrEmpty(options.totalValue) ? options.totalValue : 0) + options.value;
|
|
2281
|
-
}
|
|
2282
|
-
},
|
|
2283
|
-
format: function format(value) {
|
|
2284
|
-
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2285
|
-
var minimumFraction = isInteger ? 0 : 2;
|
|
2286
|
-
|
|
2287
|
-
var _value = isNullOrUndefinedOrEmpty(value) ? 0 : value;
|
|
2288
|
-
|
|
2289
|
-
return getNumberInSystemLocalFormat(_value, 2, minimumFraction);
|
|
2290
|
-
}
|
|
2291
|
-
};
|
|
2292
|
-
});
|
|
2293
|
-
var AllfieldsData = [].concat(pivotRowsAndColumnsFields, pivotDataCellsFields);
|
|
2294
|
-
setDataSource(new PivotGridDataSource({
|
|
2295
|
-
store: tabledata.current.PivotData,
|
|
2296
|
-
fields: AllfieldsData
|
|
2297
|
-
}));
|
|
2298
|
-
}
|
|
2299
|
-
};
|
|
2300
|
-
|
|
2301
|
-
var isRowsEmptyAndColumnsNotEmpty = function isRowsEmptyAndColumnsNotEmpty() {
|
|
2302
|
-
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
2303
|
-
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
2304
|
-
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) === 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) > 0;
|
|
2305
|
-
};
|
|
2306
|
-
|
|
2307
|
-
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
2308
|
-
if (isRowsEmptyAndColumnsNotEmpty()) {
|
|
2309
|
-
return true;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2313
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsGrandTotal) ? pivotTotalsSettings.ShowRowsGrandTotal : false;
|
|
2314
|
-
};
|
|
2315
|
-
|
|
2316
|
-
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
2317
|
-
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
2318
|
-
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
2319
|
-
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) > 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) === 0;
|
|
2320
|
-
};
|
|
2321
|
-
|
|
2322
|
-
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
2323
|
-
if (isRowsNotEmptyAndColumnsEmpty()) {
|
|
2324
|
-
return true;
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2328
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsGrandTotal) ? pivotTotalsSettings.ShowColumnsGrandTotal : false;
|
|
2329
|
-
};
|
|
2330
|
-
|
|
2331
|
-
var canShowRowsTotal = function canShowRowsTotal() {
|
|
2332
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2333
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsTotal) ? pivotTotalsSettings.ShowRowsTotal : false;
|
|
2334
|
-
};
|
|
2335
|
-
|
|
2336
|
-
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
2337
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2338
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsTotal) ? pivotTotalsSettings.ShowColumnsTotal : false;
|
|
2339
|
-
};
|
|
2340
|
-
|
|
2341
|
-
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
2342
|
-
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
2343
|
-
}, React__default.createElement(progressspinner.ProgressSpinner, {
|
|
2344
|
-
style: {
|
|
2345
|
-
width: '40px',
|
|
2346
|
-
height: '40px'
|
|
2347
|
-
},
|
|
2348
|
-
strokeWidth: "4",
|
|
2349
|
-
animationDuration: "2s"
|
|
2350
|
-
})) : React__default.createElement(PivotGrid__default, {
|
|
2351
|
-
id: "pivotGridId",
|
|
2352
|
-
ref: pivotGridRef,
|
|
2353
|
-
dataSource: dataSource,
|
|
2354
|
-
allowExpandAll: true,
|
|
2355
|
-
showBorders: true,
|
|
2356
|
-
className: 'pivot-grid-element',
|
|
2357
|
-
onCellClick: onCellClick,
|
|
2358
|
-
showRowGrandTotals: canShowRowsGrandTotal(),
|
|
2359
|
-
showColumnGrandTotals: canShowColumnsGrandTotal(),
|
|
2360
|
-
showRowTotals: canShowRowsTotal(),
|
|
2361
|
-
showColumnTotals: canShowColumnsTotal(),
|
|
2362
|
-
showTotalsPrior: 'none',
|
|
2363
|
-
wordWrapEnabled: true
|
|
2364
|
-
}, React__default.createElement(PivotGrid.FieldPanel, {
|
|
2365
|
-
showColumnFields: false,
|
|
2366
|
-
showDataFields: false,
|
|
2367
|
-
showFilterFields: false,
|
|
2368
|
-
showRowFields: false,
|
|
2369
|
-
texts: {
|
|
2370
|
-
rowFieldArea: ""
|
|
2371
|
-
},
|
|
2372
|
-
allowFieldDragging: false,
|
|
2373
|
-
visible: true
|
|
2374
|
-
}), React__default.createElement(PivotGrid.FieldChooser, {
|
|
2375
|
-
enabled: false
|
|
2376
|
-
}), React__default.createElement(PivotGrid.Scrolling, {
|
|
2377
|
-
mode: "virtual"
|
|
2378
|
-
})));
|
|
2379
|
-
});
|
|
2380
|
-
|
|
2381
|
-
var isRowPivotField = function isRowPivotField(field) {
|
|
2382
|
-
return !!(field.PivotCode && field.PivotCode.indexOf('Row') !== -1);
|
|
2383
|
-
};
|
|
2384
|
-
var truncateToTwoDecimals = function truncateToTwoDecimals(value) {
|
|
2385
|
-
var numericValue = isNullOrUndefinedOrEmpty(value) ? 0 : Number(value);
|
|
2386
|
-
var safeValue = isNaN(numericValue) ? 0 : numericValue;
|
|
2387
|
-
var decimalParts = safeValue.toString().split('.');
|
|
2388
|
-
var firstPart = decimalParts[0] ? decimalParts[0] : '0';
|
|
2389
|
-
var secondPart = decimalParts[1] ? decimalParts[1].toString().substr(0, 2) : '0';
|
|
2390
|
-
return Number(firstPart + '.' + secondPart);
|
|
2391
|
-
};
|
|
2392
|
-
var isPivotMeasureValueEmpty = function isPivotMeasureValueEmpty(value) {
|
|
2393
|
-
return value === null || value === undefined || value === '';
|
|
2394
|
-
};
|
|
2395
|
-
var logitudeSumAgg = function logitudeSumAgg(params) {
|
|
2396
|
-
var values = params && params.values ? params.values : [];
|
|
2397
|
-
if (values.length === 0) return null;
|
|
2398
|
-
var total = 0;
|
|
2399
|
-
var hasValue = false;
|
|
2400
|
-
|
|
2401
|
-
for (var i = 0; i < values.length; i++) {
|
|
2402
|
-
if (isPivotMeasureValueEmpty(values[i])) continue;
|
|
2403
|
-
hasValue = true;
|
|
2404
|
-
total += truncateToTwoDecimals(values[i]);
|
|
2405
2330
|
}
|
|
2406
2331
|
|
|
2407
|
-
return
|
|
2332
|
+
return maxValue;
|
|
2408
2333
|
};
|
|
2409
2334
|
var formatPivotMeasureValue = function formatPivotMeasureValue(value, measure) {
|
|
2410
2335
|
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2336
|
+
|
|
2337
|
+
if (isPivotDateMinMaxMeasure(measure)) {
|
|
2338
|
+
return formatPivotDateMeasureValue(value);
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2411
2341
|
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2412
2342
|
var minimumFraction = isInteger ? 0 : 2;
|
|
2413
2343
|
return getNumberInSystemLocalFormat(value, 2, minimumFraction);
|
|
@@ -2883,14 +2813,7 @@ var parsePivotTotalsSettings = function parsePivotTotalsSettings(json) {
|
|
|
2883
2813
|
}
|
|
2884
2814
|
};
|
|
2885
2815
|
|
|
2886
|
-
var
|
|
2887
|
-
|
|
2888
|
-
var applyAgGridLicense = function applyAgGridLicense() {
|
|
2889
|
-
if (!Session.AgGridLicenseKey) return;
|
|
2890
|
-
agGridEnterprise.LicenseManager.setLicenseKey(Session.AgGridLicenseKey);
|
|
2891
|
-
};
|
|
2892
|
-
|
|
2893
|
-
var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
2816
|
+
var PivotTable = React.forwardRef(function (props, comRef) {
|
|
2894
2817
|
var _useState = React.useState(),
|
|
2895
2818
|
widget = _useState[0],
|
|
2896
2819
|
setWidget = _useState[1];
|
|
@@ -2899,34 +2822,27 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
2899
2822
|
isLoading = _useState2[0],
|
|
2900
2823
|
setIsLoading = _useState2[1];
|
|
2901
2824
|
|
|
2902
|
-
var _useState3 = React.useState([]),
|
|
2903
|
-
rowData = _useState3[0],
|
|
2904
|
-
setRowData = _useState3[1];
|
|
2905
|
-
|
|
2906
|
-
var _useState4 = React.useState([]),
|
|
2907
|
-
columnDefs = _useState4[0],
|
|
2908
|
-
setColumnDefs = _useState4[1];
|
|
2909
|
-
|
|
2910
|
-
var _useState5 = React.useState(0),
|
|
2911
|
-
measureCount = _useState5[0],
|
|
2912
|
-
setMeasureCount = _useState5[1];
|
|
2913
|
-
|
|
2914
2825
|
var widgetRefData = React.useRef(null);
|
|
2915
2826
|
var tabledata = React.useRef();
|
|
2916
|
-
var
|
|
2917
|
-
var
|
|
2918
|
-
var
|
|
2919
|
-
var
|
|
2920
|
-
|
|
2827
|
+
var pivotGridRef = React.useRef(null);
|
|
2828
|
+
var dateMeasureDataFieldsRef = React.useRef(new Set());
|
|
2829
|
+
var pivotHasRowFieldsRef = React.useRef(false);
|
|
2830
|
+
var pivotHasColumnFieldsRef = React.useRef(false);
|
|
2831
|
+
|
|
2832
|
+
var _useState3 = React.useState(new PivotGridDataSource({
|
|
2833
|
+
store: [],
|
|
2834
|
+
fields: []
|
|
2835
|
+
})),
|
|
2836
|
+
dataSource = _useState3[0],
|
|
2837
|
+
setDataSource = _useState3[1];
|
|
2838
|
+
|
|
2921
2839
|
React.useEffect(function () {
|
|
2922
2840
|
var _props$customChartPro;
|
|
2923
2841
|
|
|
2924
|
-
applyAgGridLicense();
|
|
2925
|
-
|
|
2926
2842
|
if (props.customChartProps && props.customChartProps.widget) {
|
|
2927
2843
|
setWidget(props.customChartProps.widget);
|
|
2928
2844
|
widgetRefData.current = props.customChartProps.widget;
|
|
2929
|
-
getPivotTableData(
|
|
2845
|
+
getPivotTableData();
|
|
2930
2846
|
}
|
|
2931
2847
|
|
|
2932
2848
|
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
@@ -2935,58 +2851,493 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
2935
2851
|
if ((updatedWidget === null || updatedWidget === void 0 ? void 0 : updatedWidget.key) != ((_widgetRefData$curren = widgetRefData.current) === null || _widgetRefData$curren === void 0 ? void 0 : _widgetRefData$curren.key)) return;
|
|
2936
2852
|
setWidget(_extends({}, updatedWidget));
|
|
2937
2853
|
});
|
|
2938
|
-
document.addEventListener(
|
|
2854
|
+
document.addEventListener("resizeStop", handleResize);
|
|
2939
2855
|
return function () {
|
|
2940
|
-
document.removeEventListener(
|
|
2856
|
+
document.removeEventListener("resizeStop", handleResize);
|
|
2941
2857
|
};
|
|
2942
2858
|
}, []);
|
|
2943
2859
|
React.useEffect(function () {
|
|
2944
|
-
if (
|
|
2860
|
+
if (props.customChartProps.isInEditMode) {
|
|
2861
|
+
var _pivotGridRef$current;
|
|
2945
2862
|
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2863
|
+
if (pivotGridRef.current && (_pivotGridRef$current = pivotGridRef.current) !== null && _pivotGridRef$current !== void 0 && _pivotGridRef$current.instance && pivotGridRef.current.instance.element && pivotGridRef.current.instance.element().classList) {
|
|
2864
|
+
pivotGridRef.current.instance.element().classList.add('force-overflow-hidden');
|
|
2865
|
+
}
|
|
2949
2866
|
|
|
2950
|
-
|
|
2951
|
-
|
|
2867
|
+
setTimeout(function () {
|
|
2868
|
+
var _pivotGridRef$current2;
|
|
2952
2869
|
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2870
|
+
handleResize();
|
|
2871
|
+
|
|
2872
|
+
if (pivotGridRef.current && (_pivotGridRef$current2 = pivotGridRef.current) !== null && _pivotGridRef$current2 !== void 0 && _pivotGridRef$current2.instance && pivotGridRef.current.instance.element && pivotGridRef.current.instance.element().classList) {
|
|
2873
|
+
pivotGridRef.current.instance.element().classList.remove('force-overflow-hidden');
|
|
2874
|
+
}
|
|
2875
|
+
}, 5);
|
|
2876
|
+
}
|
|
2957
2877
|
}, [props.customChartProps.isInEditMode]);
|
|
2958
2878
|
|
|
2959
2879
|
var handleResize = function handleResize() {
|
|
2960
|
-
|
|
2961
|
-
|
|
2880
|
+
var _pivotGridRef$current3, _pivotGridRef$current4;
|
|
2881
|
+
|
|
2882
|
+
if (pivotGridRef.current && (_pivotGridRef$current3 = pivotGridRef.current) !== null && _pivotGridRef$current3 !== void 0 && _pivotGridRef$current3.instance && (_pivotGridRef$current4 = pivotGridRef.current) !== null && _pivotGridRef$current4 !== void 0 && _pivotGridRef$current4.instance.repaint) {
|
|
2883
|
+
var _pivotGridRef$current5;
|
|
2884
|
+
|
|
2885
|
+
(_pivotGridRef$current5 = pivotGridRef.current) === null || _pivotGridRef$current5 === void 0 ? void 0 : _pivotGridRef$current5.instance.repaint();
|
|
2962
2886
|
}
|
|
2963
2887
|
};
|
|
2964
2888
|
|
|
2965
|
-
var getPivotTableData = function getPivotTableData(
|
|
2889
|
+
var getPivotTableData = function getPivotTableData(widget) {
|
|
2966
2890
|
if (Session.Tenant == 0) {
|
|
2967
2891
|
tabledata.current = [];
|
|
2968
|
-
setRowData([]);
|
|
2969
2892
|
setIsLoading(false);
|
|
2970
2893
|
return;
|
|
2971
2894
|
}
|
|
2972
2895
|
|
|
2973
2896
|
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
2974
|
-
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive,
|
|
2975
|
-
dashboardAnalyticsService.getPivotData(
|
|
2897
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, "PostGetPivotData");
|
|
2898
|
+
dashboardAnalyticsService.getPivotData(props.customChartProps.widget).then(function (res) {
|
|
2976
2899
|
tabledata.current = res.data;
|
|
2977
|
-
|
|
2900
|
+
setPivotDataSourceFields();
|
|
2978
2901
|
setIsLoading(false);
|
|
2979
2902
|
widgetLoadLogger.log(res);
|
|
2980
2903
|
})["catch"](function (err) {
|
|
2981
|
-
console.log(
|
|
2904
|
+
console.log("Error while Getting Pivot Table Data: ", err);
|
|
2982
2905
|
tabledata.current = null;
|
|
2983
|
-
|
|
2906
|
+
setPivotDataSourceFields();
|
|
2984
2907
|
setIsLoading(false);
|
|
2985
2908
|
});
|
|
2986
2909
|
};
|
|
2987
2910
|
|
|
2988
|
-
var
|
|
2989
|
-
|
|
2911
|
+
var customizeCells = React.useCallback(function (e) {
|
|
2912
|
+
if (e.cell.rowPath && e.cell.rowPath[0] === "Germany" && e.cell.columnPath && e.cell.columnPath[0] === "Export" && e.cell.columnPath[1] === "Air") {
|
|
2913
|
+
e.cellElement.children[0].style.padding = "6px";
|
|
2914
|
+
e.cellElement.children[0].style.borderRadius = "6px";
|
|
2915
|
+
e.cellElement.children[0].style.backgroundColor = "#f4433673";
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
if (e.cell.rowPath && e.cell.rowPath[0] === "USA" && e.cell.columnPath && e.cell.columnPath[0] === "Import" && e.cell.columnPath[1] === "Inland") {
|
|
2919
|
+
e.cellElement.children[0].style.padding = "6px";
|
|
2920
|
+
e.cellElement.children[0].style.borderRadius = "6px";
|
|
2921
|
+
e.cellElement.children[0].style.backgroundColor = "#03a9f4ad";
|
|
2922
|
+
}
|
|
2923
|
+
}, []);
|
|
2924
|
+
var onCellClick = React.useCallback(function (e) {
|
|
2925
|
+
if (e.area === 'data') {
|
|
2926
|
+
var pivotFields = [];
|
|
2927
|
+
e.columnFields.forEach(function (c, index) {
|
|
2928
|
+
var fieldValue = e.cell.columnPath[index];
|
|
2929
|
+
|
|
2930
|
+
if (fieldValue !== undefined) {
|
|
2931
|
+
pivotFields.push(_extends({}, c.fieldData, {
|
|
2932
|
+
FieldValue: fieldValue
|
|
2933
|
+
}));
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
e.rowFields.forEach(function (r, index) {
|
|
2937
|
+
var fieldValue = e.cell.rowPath[index];
|
|
2938
|
+
|
|
2939
|
+
if (fieldValue !== undefined) {
|
|
2940
|
+
pivotFields.push(_extends({}, r.fieldData, {
|
|
2941
|
+
FieldValue: fieldValue
|
|
2942
|
+
}));
|
|
2943
|
+
}
|
|
2944
|
+
});
|
|
2945
|
+
props.customChartProps.onSelectDataPoint({
|
|
2946
|
+
MeasureFieldId: '',
|
|
2947
|
+
Widget: props.customChartProps.widget,
|
|
2948
|
+
MeasureCode: '',
|
|
2949
|
+
Formula: '',
|
|
2950
|
+
GroupById: '',
|
|
2951
|
+
PivotFields: pivotFields
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
}, []);
|
|
2955
|
+
var onCellPrepared = React.useCallback(function (e) {
|
|
2956
|
+
if (e.area !== 'data') {
|
|
2957
|
+
return;
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
var dataFields = e.component.getDataSource().getAreaFields('data');
|
|
2961
|
+
var dataField = dataFields && dataFields[e.cell.dataIndex];
|
|
2962
|
+
|
|
2963
|
+
if (!dataField || !dateMeasureDataFieldsRef.current.has(dataField.dataField)) {
|
|
2964
|
+
return;
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
e.cellElement.classList.add(PIVOT_DATE_DATA_CELL_CLASS);
|
|
2968
|
+
|
|
2969
|
+
if (isDevExtremePivotDataCellTotalOrGrandTotal(e.cell, pivotHasRowFieldsRef.current, pivotHasColumnFieldsRef.current)) {
|
|
2970
|
+
e.cell.text = '';
|
|
2971
|
+
var contentSpan = e.cellElement ? e.cellElement.querySelector('span') : null;
|
|
2972
|
+
|
|
2973
|
+
if (contentSpan) {
|
|
2974
|
+
contentSpan.textContent = '';
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
}, []);
|
|
2978
|
+
|
|
2979
|
+
var getColumnNameByColumnId = function getColumnNameByColumnId(fieldName, dataField, datafieldValue) {
|
|
2980
|
+
var data = tabledata.current.PivotData.find(function (el) {
|
|
2981
|
+
return el[dataField] == datafieldValue;
|
|
2982
|
+
});
|
|
2983
|
+
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2984
|
+
};
|
|
2985
|
+
|
|
2986
|
+
var SortRowAndColumnHeaders = function SortRowAndColumnHeaders(a, b, field) {
|
|
2987
|
+
if (field.DateCode == 'Month') {
|
|
2988
|
+
var aValue = a.value == null ? -1 : Number(a.value);
|
|
2989
|
+
var bValue = b.value == null ? -1 : Number(b.value);
|
|
2990
|
+
|
|
2991
|
+
if (aValue < bValue) {
|
|
2992
|
+
return -1;
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
if (aValue > bValue) {
|
|
2996
|
+
return 1;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
return 0;
|
|
3000
|
+
} else if (field.DateCode != null) {
|
|
3001
|
+
var _aValue = a.value == null ? '' : a.value;
|
|
3002
|
+
|
|
3003
|
+
var _bValue = b.value == null ? '' : b.value;
|
|
3004
|
+
|
|
3005
|
+
if (_aValue < _bValue) {
|
|
3006
|
+
return -1;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
if (_aValue > _bValue) {
|
|
3010
|
+
return 1;
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
return 0;
|
|
3014
|
+
} else {
|
|
3015
|
+
var aText = a.text == null ? '' : a.text;
|
|
3016
|
+
var bText = b.text == null ? '' : b.text;
|
|
3017
|
+
|
|
3018
|
+
if (aText < bText) {
|
|
3019
|
+
return -1;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
if (aText > bText) {
|
|
3023
|
+
return 1;
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
return 0;
|
|
3027
|
+
}
|
|
3028
|
+
};
|
|
3029
|
+
|
|
3030
|
+
var setPivotDataSourceFields = function setPivotDataSourceFields() {
|
|
3031
|
+
if (tabledata.current && tabledata.current.PivoFields && tabledata.current.PivotMeasures) {
|
|
3032
|
+
var pivotRowsAndColumnsFields = tabledata.current.PivoFields.map(function (field) {
|
|
3033
|
+
return {
|
|
3034
|
+
dataField: field.PivotCode,
|
|
3035
|
+
caption: field.DisplayName,
|
|
3036
|
+
name: field.PivotName,
|
|
3037
|
+
width: 100,
|
|
3038
|
+
allowSorting: false,
|
|
3039
|
+
allowFiltering: false,
|
|
3040
|
+
area: field.PivotCode && field.PivotCode.includes('Row') ? 'row' : 'column',
|
|
3041
|
+
sortingMethod: function sortingMethod(a, b) {
|
|
3042
|
+
return SortRowAndColumnHeaders(a, b, field);
|
|
3043
|
+
},
|
|
3044
|
+
expanded: true,
|
|
3045
|
+
wordWrapEnabled: true,
|
|
3046
|
+
fieldData: {
|
|
3047
|
+
FieldId: field.FieldId,
|
|
3048
|
+
FieldType: field.FieldType ? field.FieldType : "Field",
|
|
3049
|
+
FieldValue: '',
|
|
3050
|
+
DateCode: field.DateCode
|
|
3051
|
+
},
|
|
3052
|
+
customizeText: function customizeText(cellInfo) {
|
|
3053
|
+
return getColumnNameByColumnId(field.PivotName, field.PivotCode, cellInfo.value);
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
});
|
|
3057
|
+
var hasRowFields = tabledata.current.PivoFields.some(function (field) {
|
|
3058
|
+
return field.PivotCode && field.PivotCode.includes('Row');
|
|
3059
|
+
});
|
|
3060
|
+
var hasColumnFields = tabledata.current.PivoFields.some(function (field) {
|
|
3061
|
+
return field.PivotCode && !field.PivotCode.includes('Row');
|
|
3062
|
+
});
|
|
3063
|
+
pivotHasRowFieldsRef.current = hasRowFields;
|
|
3064
|
+
pivotHasColumnFieldsRef.current = hasColumnFields;
|
|
3065
|
+
dateMeasureDataFieldsRef.current = new Set(tabledata.current.PivotMeasures.filter(function (measure) {
|
|
3066
|
+
return (measure.MeasureCode === 'Min' || measure.MeasureCode === 'Max') && FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
3067
|
+
}).map(function (measure) {
|
|
3068
|
+
return measure.PivotMeasureCode;
|
|
3069
|
+
}));
|
|
3070
|
+
var pivotDataCellsFields = tabledata.current.PivotMeasures.map(function (measure) {
|
|
3071
|
+
var isDateMinMaxMeasure = (measure.MeasureCode === 'Min' || measure.MeasureCode === 'Max') && FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
3072
|
+
return _extends({
|
|
3073
|
+
dataField: measure.PivotMeasureCode,
|
|
3074
|
+
area: 'data',
|
|
3075
|
+
dataType: isDateMinMaxMeasure ? 'string' : 'number',
|
|
3076
|
+
wordWrapEnabled: true,
|
|
3077
|
+
caption: measure.MeasureCode == 'Sum' && typeof measure.DisplayName == 'string' ? ConvertStringToPascalCaseHelper(measure.DisplayName.replace("Sum of ", "")) : ConvertStringToPascalCaseHelper(measure.DisplayName),
|
|
3078
|
+
summaryType: 'custom',
|
|
3079
|
+
calculateCustomSummary: function calculateCustomSummary(options) {
|
|
3080
|
+
if (options.summaryProcess == 'start') {
|
|
3081
|
+
options.totalValue = null;
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
if (options.summaryProcess != 'calculate') {
|
|
3086
|
+
return;
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
if (isDateMinMaxMeasure) {
|
|
3090
|
+
if (isNullOrUndefinedOrEmpty(options.value)) {
|
|
3091
|
+
return;
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
var currentDate = moment(options.value);
|
|
3095
|
+
|
|
3096
|
+
if (!currentDate || !currentDate.isValid()) {
|
|
3097
|
+
return;
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
if (isNullOrUndefinedOrEmpty(options.totalValue)) {
|
|
3101
|
+
options.totalValue = options.value;
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
var totalDate = moment(options.totalValue);
|
|
3106
|
+
|
|
3107
|
+
if (!totalDate || !totalDate.isValid()) {
|
|
3108
|
+
options.totalValue = options.value;
|
|
3109
|
+
return;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
if (measure.MeasureCode === 'Max') {
|
|
3113
|
+
if (currentDate.isAfter(totalDate)) {
|
|
3114
|
+
options.totalValue = options.value;
|
|
3115
|
+
}
|
|
3116
|
+
} else if (currentDate.isBefore(totalDate)) {
|
|
3117
|
+
options.totalValue = options.value;
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
return;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
var _value = !isNullOrUndefinedOrEmpty(options.value) ? options.value : 0;
|
|
3124
|
+
|
|
3125
|
+
var decimalParts = _value.toString().split(".");
|
|
3126
|
+
|
|
3127
|
+
var firstPart = decimalParts[0] ? decimalParts[0] : 0;
|
|
3128
|
+
var secondPart = decimalParts[1] ? decimalParts[1] : 0;
|
|
3129
|
+
secondPart = secondPart.toString().substr(0, 2);
|
|
3130
|
+
|
|
3131
|
+
var _finalVal = firstPart + "." + secondPart;
|
|
3132
|
+
|
|
3133
|
+
options.value = Number(_finalVal);
|
|
3134
|
+
options.totalValue = (!isNullOrUndefinedOrEmpty(options.totalValue) ? options.totalValue : 0) + options.value;
|
|
3135
|
+
}
|
|
3136
|
+
}, isDateMinMaxMeasure ? {
|
|
3137
|
+
calculateSummaryValue: function calculateSummaryValue(cell) {
|
|
3138
|
+
if (isDevExtremeSummaryCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields)) {
|
|
3139
|
+
return null;
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
return cell.value();
|
|
3143
|
+
},
|
|
3144
|
+
customizeText: function customizeText(cellInfo) {
|
|
3145
|
+
return formatPivotDateMeasureValue(cellInfo.value);
|
|
3146
|
+
}
|
|
3147
|
+
} : {
|
|
3148
|
+
format: function format(value) {
|
|
3149
|
+
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
3150
|
+
var minimumFraction = isInteger ? 0 : 2;
|
|
3151
|
+
|
|
3152
|
+
var _value = isNullOrUndefinedOrEmpty(value) ? 0 : value;
|
|
3153
|
+
|
|
3154
|
+
return getNumberInSystemLocalFormat(_value, 2, minimumFraction);
|
|
3155
|
+
}
|
|
3156
|
+
});
|
|
3157
|
+
});
|
|
3158
|
+
var AllfieldsData = [].concat(pivotRowsAndColumnsFields, pivotDataCellsFields);
|
|
3159
|
+
setDataSource(new PivotGridDataSource({
|
|
3160
|
+
store: tabledata.current.PivotData,
|
|
3161
|
+
fields: AllfieldsData
|
|
3162
|
+
}));
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
|
|
3166
|
+
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3167
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3168
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsGrandTotal) ? pivotTotalsSettings.ShowRowsGrandTotal : false;
|
|
3169
|
+
};
|
|
3170
|
+
|
|
3171
|
+
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
3172
|
+
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
3173
|
+
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
3174
|
+
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) > 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) === 0;
|
|
3175
|
+
};
|
|
3176
|
+
|
|
3177
|
+
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
3178
|
+
if (isRowsNotEmptyAndColumnsEmpty()) {
|
|
3179
|
+
return true;
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3183
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsGrandTotal) ? pivotTotalsSettings.ShowColumnsGrandTotal : false;
|
|
3184
|
+
};
|
|
3185
|
+
|
|
3186
|
+
var canShowRowsTotal = function canShowRowsTotal() {
|
|
3187
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3188
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsTotal) ? pivotTotalsSettings.ShowRowsTotal : false;
|
|
3189
|
+
};
|
|
3190
|
+
|
|
3191
|
+
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
3192
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3193
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsTotal) ? pivotTotalsSettings.ShowColumnsTotal : false;
|
|
3194
|
+
};
|
|
3195
|
+
|
|
3196
|
+
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
3197
|
+
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
3198
|
+
}, React__default.createElement(progressspinner.ProgressSpinner, {
|
|
3199
|
+
style: {
|
|
3200
|
+
width: '40px',
|
|
3201
|
+
height: '40px'
|
|
3202
|
+
},
|
|
3203
|
+
strokeWidth: "4",
|
|
3204
|
+
animationDuration: "2s"
|
|
3205
|
+
})) : React__default.createElement(PivotGrid__default, {
|
|
3206
|
+
id: "pivotGridId",
|
|
3207
|
+
ref: pivotGridRef,
|
|
3208
|
+
dataSource: dataSource,
|
|
3209
|
+
allowExpandAll: true,
|
|
3210
|
+
showBorders: true,
|
|
3211
|
+
className: 'pivot-grid-element',
|
|
3212
|
+
onCellClick: onCellClick,
|
|
3213
|
+
onCellPrepared: onCellPrepared,
|
|
3214
|
+
showRowGrandTotals: canShowRowsGrandTotal(),
|
|
3215
|
+
showColumnGrandTotals: canShowColumnsGrandTotal(),
|
|
3216
|
+
showRowTotals: canShowRowsTotal(),
|
|
3217
|
+
showColumnTotals: canShowColumnsTotal(),
|
|
3218
|
+
showTotalsPrior: 'none',
|
|
3219
|
+
wordWrapEnabled: true
|
|
3220
|
+
}, React__default.createElement(PivotGrid.FieldPanel, {
|
|
3221
|
+
showColumnFields: false,
|
|
3222
|
+
showDataFields: false,
|
|
3223
|
+
showFilterFields: false,
|
|
3224
|
+
showRowFields: false,
|
|
3225
|
+
texts: {
|
|
3226
|
+
rowFieldArea: ""
|
|
3227
|
+
},
|
|
3228
|
+
allowFieldDragging: false,
|
|
3229
|
+
visible: true
|
|
3230
|
+
}), React__default.createElement(PivotGrid.FieldChooser, {
|
|
3231
|
+
enabled: false
|
|
3232
|
+
}), React__default.createElement(PivotGrid.Scrolling, {
|
|
3233
|
+
mode: "virtual"
|
|
3234
|
+
})));
|
|
3235
|
+
});
|
|
3236
|
+
|
|
3237
|
+
var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
|
|
3238
|
+
|
|
3239
|
+
var applyAgGridLicense = function applyAgGridLicense() {
|
|
3240
|
+
if (!Session.AgGridLicenseKey) return;
|
|
3241
|
+
agGridEnterprise.LicenseManager.setLicenseKey(Session.AgGridLicenseKey);
|
|
3242
|
+
};
|
|
3243
|
+
|
|
3244
|
+
var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
3245
|
+
var _useState = React.useState(),
|
|
3246
|
+
widget = _useState[0],
|
|
3247
|
+
setWidget = _useState[1];
|
|
3248
|
+
|
|
3249
|
+
var _useState2 = React.useState(true),
|
|
3250
|
+
isLoading = _useState2[0],
|
|
3251
|
+
setIsLoading = _useState2[1];
|
|
3252
|
+
|
|
3253
|
+
var _useState3 = React.useState([]),
|
|
3254
|
+
rowData = _useState3[0],
|
|
3255
|
+
setRowData = _useState3[1];
|
|
3256
|
+
|
|
3257
|
+
var _useState4 = React.useState([]),
|
|
3258
|
+
columnDefs = _useState4[0],
|
|
3259
|
+
setColumnDefs = _useState4[1];
|
|
3260
|
+
|
|
3261
|
+
var _useState5 = React.useState(0),
|
|
3262
|
+
measureCount = _useState5[0],
|
|
3263
|
+
setMeasureCount = _useState5[1];
|
|
3264
|
+
|
|
3265
|
+
var widgetRefData = React.useRef(null);
|
|
3266
|
+
var tabledata = React.useRef();
|
|
3267
|
+
var gridApiRef = React.useRef(null);
|
|
3268
|
+
var columnApiRef = React.useRef(null);
|
|
3269
|
+
var gridContainerRef = React.useRef(null);
|
|
3270
|
+
var pivotFieldsRef = React.useRef([]);
|
|
3271
|
+
var pivotMeasuresRef = React.useRef([]);
|
|
3272
|
+
React.useEffect(function () {
|
|
3273
|
+
var _props$customChartPro;
|
|
3274
|
+
|
|
3275
|
+
applyAgGridLicense();
|
|
3276
|
+
|
|
3277
|
+
if (props.customChartProps && props.customChartProps.widget) {
|
|
3278
|
+
setWidget(props.customChartProps.widget);
|
|
3279
|
+
widgetRefData.current = props.customChartProps.widget;
|
|
3280
|
+
getPivotTableData(props.customChartProps.widget);
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
3284
|
+
var _widgetRefData$curren;
|
|
3285
|
+
|
|
3286
|
+
if ((updatedWidget === null || updatedWidget === void 0 ? void 0 : updatedWidget.key) != ((_widgetRefData$curren = widgetRefData.current) === null || _widgetRefData$curren === void 0 ? void 0 : _widgetRefData$curren.key)) return;
|
|
3287
|
+
setWidget(_extends({}, updatedWidget));
|
|
3288
|
+
});
|
|
3289
|
+
document.addEventListener('resizeStop', handleResize);
|
|
3290
|
+
return function () {
|
|
3291
|
+
document.removeEventListener('resizeStop', handleResize);
|
|
3292
|
+
};
|
|
3293
|
+
}, []);
|
|
3294
|
+
React.useEffect(function () {
|
|
3295
|
+
if (!props.customChartProps.isInEditMode) return;
|
|
3296
|
+
|
|
3297
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
3298
|
+
gridContainerRef.current.classList.add('force-overflow-hidden');
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
setTimeout(function () {
|
|
3302
|
+
handleResize();
|
|
3303
|
+
|
|
3304
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
3305
|
+
gridContainerRef.current.classList.remove('force-overflow-hidden');
|
|
3306
|
+
}
|
|
3307
|
+
}, 5);
|
|
3308
|
+
}, [props.customChartProps.isInEditMode]);
|
|
3309
|
+
|
|
3310
|
+
var handleResize = function handleResize() {
|
|
3311
|
+
if (gridApiRef.current && gridApiRef.current.resetRowHeights) {
|
|
3312
|
+
gridApiRef.current.resetRowHeights();
|
|
3313
|
+
}
|
|
3314
|
+
};
|
|
3315
|
+
|
|
3316
|
+
var getPivotTableData = function getPivotTableData(widgetPm) {
|
|
3317
|
+
if (Session.Tenant == 0) {
|
|
3318
|
+
tabledata.current = [];
|
|
3319
|
+
setRowData([]);
|
|
3320
|
+
setIsLoading(false);
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
3325
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, 'PostGetPivotData');
|
|
3326
|
+
dashboardAnalyticsService.getPivotData(widgetPm).then(function (res) {
|
|
3327
|
+
tabledata.current = res.data;
|
|
3328
|
+
buildGridFromPivotResponse();
|
|
3329
|
+
setIsLoading(false);
|
|
3330
|
+
widgetLoadLogger.log(res);
|
|
3331
|
+
})["catch"](function (err) {
|
|
3332
|
+
console.log('Error while Getting Pivot Table Data: ', err);
|
|
3333
|
+
tabledata.current = null;
|
|
3334
|
+
setRowData([]);
|
|
3335
|
+
setIsLoading(false);
|
|
3336
|
+
});
|
|
3337
|
+
};
|
|
3338
|
+
|
|
3339
|
+
var lookupDisplayName = function lookupDisplayName(field, rawValue) {
|
|
3340
|
+
var pivotData = tabledata.current && tabledata.current.PivotData ? tabledata.current.PivotData : [];
|
|
2990
3341
|
return getPivotDisplayName(pivotData, field.PivotName, field.PivotCode, rawValue);
|
|
2991
3342
|
};
|
|
2992
3343
|
|
|
@@ -2998,11 +3349,14 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
2998
3349
|
return lookupDisplayName(field, rawValue);
|
|
2999
3350
|
};
|
|
3000
3351
|
|
|
3001
|
-
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef) {
|
|
3352
|
+
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef, measure) {
|
|
3002
3353
|
colDef.sortable = false;
|
|
3003
3354
|
colDef.filter = false;
|
|
3004
|
-
colDef.cellClass = 'dl-ag-pivot-data-cell';
|
|
3005
|
-
|
|
3355
|
+
colDef.cellClass = measure ? getPivotDataCellClassNames(measure) : 'dl-ag-pivot-data-cell';
|
|
3356
|
+
|
|
3357
|
+
if (!measure || !isPivotDateMinMaxMeasure(measure)) {
|
|
3358
|
+
colDef.type = 'numericColumn';
|
|
3359
|
+
}
|
|
3006
3360
|
};
|
|
3007
3361
|
|
|
3008
3362
|
var buildGridFromPivotResponse = function buildGridFromPivotResponse() {
|
|
@@ -3072,28 +3426,36 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
3072
3426
|
};
|
|
3073
3427
|
};
|
|
3074
3428
|
|
|
3429
|
+
var getMeasureAggFunc = function getMeasureAggFunc(measure) {
|
|
3430
|
+
if (!isPivotDateMinMaxMeasure(measure)) return 'logitudeSum';
|
|
3431
|
+
return measure.MeasureCode === 'Max' ? 'logitudeMax' : 'logitudeMin';
|
|
3432
|
+
};
|
|
3433
|
+
|
|
3075
3434
|
var createMeasureColDef = function createMeasureColDef(measure) {
|
|
3076
|
-
|
|
3435
|
+
var colDef = {
|
|
3077
3436
|
field: measure.PivotMeasureCode,
|
|
3078
3437
|
headerName: getMeasureCaption(measure),
|
|
3079
|
-
aggFunc:
|
|
3438
|
+
aggFunc: getMeasureAggFunc(measure),
|
|
3080
3439
|
enableValue: true,
|
|
3081
3440
|
wrapText: true,
|
|
3082
3441
|
autoHeight: true,
|
|
3083
3442
|
sortable: false,
|
|
3084
3443
|
filter: false,
|
|
3085
|
-
cellClass:
|
|
3086
|
-
type: 'numericColumn',
|
|
3444
|
+
cellClass: getPivotDataCellClassNames(measure),
|
|
3087
3445
|
valueFormatter: function valueFormatter(params) {
|
|
3446
|
+
if (isPivotDateMinMaxMeasure(measure) && isAgGridPivotDateMeasureTotalDisplayCell(params)) {
|
|
3447
|
+
return '';
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3088
3450
|
return formatPivotMeasureValue(params.value, measure);
|
|
3089
3451
|
}
|
|
3090
3452
|
};
|
|
3091
|
-
};
|
|
3092
3453
|
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3454
|
+
if (!isPivotDateMinMaxMeasure(measure)) {
|
|
3455
|
+
colDef.type = 'numericColumn';
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
return colDef;
|
|
3097
3459
|
};
|
|
3098
3460
|
|
|
3099
3461
|
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
@@ -3103,7 +3465,6 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
3103
3465
|
};
|
|
3104
3466
|
|
|
3105
3467
|
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3106
|
-
if (isRowsEmptyAndColumnsNotEmpty()) return true;
|
|
3107
3468
|
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3108
3469
|
return !isNullOrUndefinedOrEmpty(settings.ShowRowsGrandTotal) ? !!settings.ShowRowsGrandTotal : false;
|
|
3109
3470
|
};
|
|
@@ -3151,12 +3512,18 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
3151
3512
|
}
|
|
3152
3513
|
}
|
|
3153
3514
|
|
|
3154
|
-
|
|
3515
|
+
var measure = resolveMeasureForSecondaryColDef(colDef, pivotMeasuresRef.current);
|
|
3516
|
+
applyPivotDataCellFormatting(colDef, measure);
|
|
3155
3517
|
|
|
3156
3518
|
colDef.valueFormatter = function (params) {
|
|
3157
|
-
var
|
|
3158
|
-
if (!
|
|
3159
|
-
|
|
3519
|
+
var resolvedMeasure = measure || resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
|
|
3520
|
+
if (!resolvedMeasure) return '';
|
|
3521
|
+
|
|
3522
|
+
if (isPivotDateMinMaxMeasure(resolvedMeasure) && isAgGridPivotDateMeasureTotalDisplayCell(params)) {
|
|
3523
|
+
return '';
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3526
|
+
return formatPivotMeasureValue(params.value, resolvedMeasure);
|
|
3160
3527
|
};
|
|
3161
3528
|
}, []);
|
|
3162
3529
|
var onCellClicked = React.useCallback(function (event) {
|
|
@@ -3222,7 +3589,9 @@ var AgPivotGrid = React.forwardRef(function (props, _comRef) {
|
|
|
3222
3589
|
}, []);
|
|
3223
3590
|
var aggFuncs = React.useMemo(function () {
|
|
3224
3591
|
return {
|
|
3225
|
-
logitudeSum: logitudeSumAgg
|
|
3592
|
+
logitudeSum: logitudeSumAgg,
|
|
3593
|
+
logitudeMin: logitudeMinAgg,
|
|
3594
|
+
logitudeMax: logitudeMaxAgg
|
|
3226
3595
|
};
|
|
3227
3596
|
}, []);
|
|
3228
3597
|
var scheduleRowGrandTotalHeaderLabel = React.useCallback(function () {
|