logitude-dashboard-library 3.2.62 → 3.2.64

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.
@@ -8,6 +8,10 @@ import { DataTable } from 'primereact/datatable';
8
8
  import { Column } from 'primereact/column';
9
9
  import PivotGrid, { FieldPanel, FieldChooser, Scrolling } from 'devextreme-react/pivot-grid';
10
10
  import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
11
+ import { AgGridReact } from 'ag-grid-react';
12
+ import { LicenseManager } from 'ag-grid-enterprise';
13
+ import 'ag-grid-community/dist/styles/ag-grid.css';
14
+ import 'ag-grid-community/dist/styles/ag-theme-balham.css';
11
15
  import ReactFC from 'react-fusioncharts';
12
16
  import FusionCharts from 'fusioncharts';
13
17
  import Charts from 'fusioncharts/fusioncharts.charts';
@@ -77,6 +81,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
77
81
  }
78
82
 
79
83
  var Session = function Session() {};
84
+ Session.UseAgGridPivot = false;
80
85
 
81
86
  var Tools = /*#__PURE__*/function () {
82
87
  function Tools() {}
@@ -588,7 +593,103 @@ var getLast30DaysDates = function getLast30DaysDates(format) {
588
593
  return dateValues;
589
594
  };
590
595
 
591
- var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate) {
596
+ var getDateRangesByPeriod = function getDateRangesByPeriod(_operator, _interval, _range, _format) {
597
+ if (_format === void 0) {
598
+ _format = "YYYYMMDD000000";
599
+ }
600
+
601
+ if (!_operator || !_interval || !_range) return null;
602
+ var result = {
603
+ date1: null,
604
+ date2: null
605
+ };
606
+
607
+ if (_operator.toLowerCase() == 'current') {
608
+ switch (_range) {
609
+ case "Day":
610
+ result.date1 = getTodayDates()[0];
611
+ result.date2 = getTodayDates()[1];
612
+ break;
613
+
614
+ case "Week":
615
+ result.date1 = getCurrentWeekDates()[0];
616
+ result.date2 = getCurrentWeekDates()[1];
617
+ break;
618
+
619
+ case "Month":
620
+ result.date1 = getCurrentMonthDates()[0];
621
+ result.date2 = getCurrentMonthDates()[1];
622
+ break;
623
+
624
+ case "Current_Month_To_Date":
625
+ case "Month To Date":
626
+ result.date1 = getCurrentMonthToDateDates()[0];
627
+ result.date2 = getCurrentMonthToDateDates()[1];
628
+ break;
629
+
630
+ case "Quarter":
631
+ result.date1 = getCurrentQuarterDates()[0];
632
+ result.date2 = getCurrentQuarterDates()[1];
633
+ break;
634
+
635
+ case "Current_Quarter_To_Date":
636
+ case "Quarter To Date":
637
+ result.date1 = getCurrentQuarterToDateDates()[0];
638
+ result.date2 = getCurrentQuarterToDateDates()[1];
639
+ break;
640
+
641
+ case "Year":
642
+ result.date1 = getCurrentYearDates()[0];
643
+ result.date2 = getCurrentYearDates()[1];
644
+ break;
645
+
646
+ case "Current_Year_To_Date":
647
+ case "Year To Date":
648
+ result.date1 = getCurrentYearToDateDates()[0];
649
+ result.date2 = getCurrentYearToDateDates()[1];
650
+ break;
651
+ }
652
+ } else {
653
+ var dateGroupCodes = {
654
+ 'Day': 'days',
655
+ 'Week': 'weeks',
656
+ 'Month': 'months',
657
+ 'Quarter': 'quarters',
658
+ 'Year': 'years',
659
+ 'Year To Date': 'years',
660
+ 'Quarter To Date': 'quarters',
661
+ 'Month To Date': 'months'
662
+ };
663
+ var customDateGroupCodes = ['Year To Date', 'Quarter To Date', 'Month To Date'];
664
+
665
+ if (_operator.toLowerCase() == 'next') {
666
+ result.date1 = moment().startOf(dateGroupCodes[_range]).add(1, dateGroupCodes[_range]).format(_format);
667
+ result.date2 = moment().startOf(dateGroupCodes[_range]).add(Number(_interval), dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
668
+ } else if (_operator.toLowerCase() == 'previous' && !customDateGroupCodes.includes(_range)) {
669
+ result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
670
+ result.date2 = moment().subtract(1, dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
671
+ } else if (_operator.toLowerCase() == 'previous' && customDateGroupCodes.includes(_range)) {
672
+ result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
673
+ result.date2 = moment().format(_format);
674
+ }
675
+ }
676
+
677
+ return result;
678
+ };
679
+
680
+ var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate, _operator, _interval, _range) {
681
+ if (_operator === void 0) {
682
+ _operator = null;
683
+ }
684
+
685
+ if (_interval === void 0) {
686
+ _interval = null;
687
+ }
688
+
689
+ if (_range === void 0) {
690
+ _range = null;
691
+ }
692
+
592
693
  var result = {
593
694
  fromDate: null,
594
695
  toDate: null
@@ -696,6 +797,12 @@ var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate)
696
797
  result.fromDate = getCurrentWeekDates()[0];
697
798
  result.toDate = getCurrentWeekDates()[1];
698
799
  break;
800
+
801
+ case "Previous_Next":
802
+ var previousNextDates = getDateRangesByPeriod(_operator || "", _interval || "", _range || "");
803
+ result.fromDate = previousNextDates && previousNextDates.date1 ? previousNextDates.date1 : null;
804
+ result.toDate = previousNextDates && previousNextDates.date2 ? previousNextDates.date2 : null;
805
+ break;
699
806
  }
700
807
 
701
808
  return result;
@@ -1094,11 +1201,18 @@ var KpiChart = function KpiChart(props) {
1094
1201
 
1095
1202
  if (isKPISettingsActivated) {
1096
1203
  var PeriodDateFilterDates = getDateRangesByCode(kpiSettings.PeriodDateFilter.DateTimeValueCode, null, null);
1097
- var ComparePeriodDateFilterDates = kpiSettings.ComparisonPeriodType == 'Manually' ? getDateRangesByCode(kpiSettings.ComparePeriodDateFilter.DateTimeValueCode, kpiSettings.ComparePeriodDateFilter.FieldValue, kpiSettings.ComparePeriodDateFilter.FieldValue2) : getDateRangesByCode(null, null, null);
1204
+ var comparePeriodOperator = kpiSettings.ComparePeriodDateFilter.DateRangeOperator || kpiSettings.ComparePeriodDateFilter.Operator;
1205
+ var comparePeriodInterval = kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue != null ? String(kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue) : null;
1206
+ var ComparePeriodDateFilterDates = kpiSettings.ComparisonPeriodType == 'Manually' ? getDateRangesByCode(kpiSettings.ComparePeriodDateFilter.DateTimeValueCode, kpiSettings.ComparePeriodDateFilter.FieldValue, kpiSettings.ComparePeriodDateFilter.FieldValue2, comparePeriodOperator, comparePeriodInterval, kpiSettings.ComparePeriodDateFilter.DateGroupCode) : getDateRangesByCode(null, null, null);
1098
1207
  kpiSettings.PeriodDateFilter.FieldValue = PeriodDateFilterDates.fromDate;
1099
1208
  kpiSettings.PeriodDateFilter.FieldValue2 = PeriodDateFilterDates.toDate;
1100
1209
  kpiSettings.ComparePeriodDateFilter.FieldValue = ComparePeriodDateFilterDates.fromDate;
1101
1210
  kpiSettings.ComparePeriodDateFilter.FieldValue2 = ComparePeriodDateFilterDates.toDate;
1211
+
1212
+ if (kpiSettings.ComparisonPeriodType == 'Manually' && kpiSettings.ComparePeriodDateFilter.DateTimeValueCode == 'Previous_Next') {
1213
+ kpiSettings.ComparePeriodDateFilter.Operator = 'Between';
1214
+ }
1215
+
1102
1216
  _updatedWidget.KPIComparisonSettings = JSON.stringify(kpiSettings);
1103
1217
  }
1104
1218
 
@@ -2369,6 +2483,943 @@ var PivotTable = forwardRef(function (props, comRef) {
2369
2483
  })));
2370
2484
  });
2371
2485
 
2486
+ var isRowPivotField = function isRowPivotField(field) {
2487
+ return !!(field.PivotCode && field.PivotCode.indexOf('Row') !== -1);
2488
+ };
2489
+ var truncateToTwoDecimals = function truncateToTwoDecimals(value) {
2490
+ var numericValue = isNullOrUndefinedOrEmpty(value) ? 0 : Number(value);
2491
+ var safeValue = isNaN(numericValue) ? 0 : numericValue;
2492
+ var decimalParts = safeValue.toString().split('.');
2493
+ var firstPart = decimalParts[0] ? decimalParts[0] : '0';
2494
+ var secondPart = decimalParts[1] ? decimalParts[1].toString().substr(0, 2) : '0';
2495
+ return Number(firstPart + '.' + secondPart);
2496
+ };
2497
+ var isPivotMeasureValueEmpty = function isPivotMeasureValueEmpty(value) {
2498
+ return value === null || value === undefined || value === '';
2499
+ };
2500
+ var logitudeSumAgg = function logitudeSumAgg(params) {
2501
+ var values = params && params.values ? params.values : [];
2502
+ if (values.length === 0) return null;
2503
+ var total = 0;
2504
+ var hasValue = false;
2505
+
2506
+ for (var i = 0; i < values.length; i++) {
2507
+ if (isPivotMeasureValueEmpty(values[i])) continue;
2508
+ hasValue = true;
2509
+ total += truncateToTwoDecimals(values[i]);
2510
+ }
2511
+
2512
+ return hasValue ? total : null;
2513
+ };
2514
+ var formatPivotMeasureValue = function formatPivotMeasureValue(value, measure) {
2515
+ if (isPivotMeasureValueEmpty(value)) return '';
2516
+ var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
2517
+ var minimumFraction = isInteger ? 0 : 2;
2518
+ return getNumberInSystemLocalFormat(value, 2, minimumFraction);
2519
+ };
2520
+ var getPivotGroupFooterLabel = function getPivotGroupFooterLabel(node, fieldCode, rawValue, lookupDisplayName) {
2521
+ if (!node || !node.footer) return '';
2522
+
2523
+ if (node.level === -1) {
2524
+ return 'Grand Total';
2525
+ }
2526
+
2527
+ if (!fieldCode) return '';
2528
+ var displayName = lookupDisplayName(fieldCode, rawValue);
2529
+ return displayName ? displayName + " Total" : '';
2530
+ };
2531
+ var compareDimensionValues = function compareDimensionValues(aValue, bValue, dateCode, aText, bText) {
2532
+ if (dateCode === 'Month') {
2533
+ var aNumber = aValue == null ? -1 : Number(aValue);
2534
+ var bNumber = bValue == null ? -1 : Number(bValue);
2535
+ if (aNumber < bNumber) return -1;
2536
+ if (aNumber > bNumber) return 1;
2537
+ return 0;
2538
+ }
2539
+
2540
+ if (dateCode != null) {
2541
+ var aCompare = aValue == null ? '' : aValue;
2542
+ var bCompare = bValue == null ? '' : bValue;
2543
+ if (aCompare < bCompare) return -1;
2544
+ if (aCompare > bCompare) return 1;
2545
+ return 0;
2546
+ }
2547
+
2548
+ var aDisplay = aText == null || aText === '' ? aValue == null ? '' : aValue : aText;
2549
+ var bDisplay = bText == null || bText === '' ? bValue == null ? '' : bValue : bText;
2550
+ if (aDisplay < bDisplay) return -1;
2551
+ if (aDisplay > bDisplay) return 1;
2552
+ return 0;
2553
+ };
2554
+ var getPivotDisplayName = function getPivotDisplayName(pivotData, fieldName, dataField, dataFieldValue) {
2555
+ if (!pivotData || pivotData.length === 0) return '';
2556
+ var data = pivotData.find(function (el) {
2557
+ return el[dataField] == dataFieldValue;
2558
+ });
2559
+ return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
2560
+ };
2561
+ var isPivotRowGrandTotalColumnDef = function isPivotRowGrandTotalColumnDef(colDef) {
2562
+ if (!colDef || !colDef.colId) {
2563
+ return false;
2564
+ }
2565
+
2566
+ return String(colDef.colId).indexOf('PivotRowTotal_') === 0;
2567
+ };
2568
+ var isPivotRowGrandTotalGroupDef = function isPivotRowGrandTotalGroupDef(colGroupDef) {
2569
+ if (!colGroupDef) {
2570
+ return false;
2571
+ }
2572
+
2573
+ var groupId = colGroupDef.groupId || colGroupDef.colId || '';
2574
+
2575
+ if (String(groupId).indexOf('PivotRowTotal') >= 0) {
2576
+ return true;
2577
+ }
2578
+
2579
+ var children = colGroupDef.children;
2580
+
2581
+ if (!children || children.length === 0) {
2582
+ return false;
2583
+ }
2584
+
2585
+ return children.every(function (child) {
2586
+ if (child && child.children) {
2587
+ return isPivotRowGrandTotalGroupDef(child);
2588
+ }
2589
+
2590
+ return isPivotRowGrandTotalColumnDef(child);
2591
+ });
2592
+ };
2593
+ var resolvePivotGroupHeaderName = function resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName) {
2594
+ if (isPivotRowGrandTotalGroupDef(colGroupDef)) {
2595
+ return 'Grand Total';
2596
+ }
2597
+
2598
+ var pivotKeys = colGroupDef && colGroupDef.pivotKeys ? colGroupDef.pivotKeys : [];
2599
+
2600
+ if (pivotKeys.length === 0) {
2601
+ return null;
2602
+ }
2603
+
2604
+ var field = columnFields[pivotKeys.length - 1];
2605
+
2606
+ if (!field) {
2607
+ return null;
2608
+ }
2609
+
2610
+ return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
2611
+ };
2612
+ var getPivotValueColumnId = function getPivotValueColumnId(pivotValueColumn) {
2613
+ if (!pivotValueColumn) {
2614
+ return null;
2615
+ }
2616
+
2617
+ if (typeof pivotValueColumn.getId === 'function') {
2618
+ return pivotValueColumn.getId();
2619
+ }
2620
+
2621
+ if (typeof pivotValueColumn.getColId === 'function') {
2622
+ return pivotValueColumn.getColId();
2623
+ }
2624
+
2625
+ if (pivotValueColumn.colId) {
2626
+ return String(pivotValueColumn.colId);
2627
+ }
2628
+
2629
+ if (pivotValueColumn.field) {
2630
+ return String(pivotValueColumn.field);
2631
+ }
2632
+
2633
+ return null;
2634
+ };
2635
+ var resolveMeasureFromPivotValueColumn = function resolveMeasureFromPivotValueColumn(colDef, measures) {
2636
+ if (!colDef || measures.length === 0) {
2637
+ return undefined;
2638
+ }
2639
+
2640
+ if (measures.length === 1) {
2641
+ return measures[0];
2642
+ }
2643
+
2644
+ var valueColumnId = getPivotValueColumnId(colDef.pivotValueColumn);
2645
+
2646
+ if (valueColumnId) {
2647
+ var measureByValueColumn = measures.find(function (measure) {
2648
+ return measure.PivotMeasureCode === valueColumnId;
2649
+ });
2650
+
2651
+ if (measureByValueColumn) {
2652
+ return measureByValueColumn;
2653
+ }
2654
+ }
2655
+
2656
+ var colId = colDef.colId ? String(colDef.colId) : '';
2657
+
2658
+ if (colId) {
2659
+ var sortedMeasures = [].concat(measures).sort(function (left, right) {
2660
+ return right.PivotMeasureCode.length - left.PivotMeasureCode.length;
2661
+ });
2662
+
2663
+ for (var index = 0; index < sortedMeasures.length; index++) {
2664
+ var measureCode = sortedMeasures[index].PivotMeasureCode;
2665
+
2666
+ if (colId.endsWith('_' + measureCode)) {
2667
+ return sortedMeasures[index];
2668
+ }
2669
+ }
2670
+ }
2671
+
2672
+ return undefined;
2673
+ };
2674
+ var resolvePivotLeafHeaderName = function resolvePivotLeafHeaderName(colDef, columnFields, lookupDisplayName, measureCount, measures) {
2675
+ if (isPivotRowGrandTotalColumnDef(colDef)) {
2676
+ return null;
2677
+ }
2678
+
2679
+ if (measureCount > 1 && colDef.pivotValueColumn) {
2680
+ return null;
2681
+ }
2682
+
2683
+ var pivotKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
2684
+
2685
+ if (pivotKeys.length === 0) {
2686
+ return null;
2687
+ }
2688
+
2689
+ var field = columnFields[pivotKeys.length - 1];
2690
+
2691
+ if (!field) {
2692
+ return null;
2693
+ }
2694
+
2695
+ return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
2696
+ };
2697
+ var resolveMeasureForSecondaryColDef = function resolveMeasureForSecondaryColDef(colDef, measures) {
2698
+ return resolveMeasureFromPivotValueColumn(colDef, measures);
2699
+ };
2700
+
2701
+ var getColumnGroupAtHeaderLevel = function getColumnGroupAtHeaderLevel(column, targetLevel) {
2702
+ if (!column || typeof column.getParent !== 'function') {
2703
+ return null;
2704
+ }
2705
+
2706
+ var groupPointer = column.getParent();
2707
+
2708
+ while (groupPointer) {
2709
+ var providedColumnGroup = typeof groupPointer.getProvidedColumnGroup === 'function' ? groupPointer.getProvidedColumnGroup() : null;
2710
+
2711
+ if (!providedColumnGroup) {
2712
+ groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
2713
+ continue;
2714
+ }
2715
+
2716
+ var originalGroupLevel = typeof providedColumnGroup.getLevel === 'function' ? providedColumnGroup.getLevel() : 0;
2717
+ var groupPointerLevel = typeof groupPointer.getPaddingLevel === 'function' ? groupPointer.getPaddingLevel() : 0;
2718
+
2719
+ if (originalGroupLevel + groupPointerLevel <= targetLevel) {
2720
+ return groupPointer;
2721
+ }
2722
+
2723
+ groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
2724
+ }
2725
+
2726
+ return null;
2727
+ };
2728
+
2729
+ var escapeColumnIdSelector = function escapeColumnIdSelector(columnId) {
2730
+ if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {
2731
+ return CSS.escape(columnId);
2732
+ }
2733
+
2734
+ return columnId.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
2735
+ };
2736
+
2737
+ var findHeaderGroupCellByColumnGroup = function findHeaderGroupCellByColumnGroup(headerContainer, groupRows, targetGroupLevel, columnGroup) {
2738
+ if (!columnGroup || typeof columnGroup.getUniqueId !== 'function') {
2739
+ return null;
2740
+ }
2741
+
2742
+ var groupId = columnGroup.getUniqueId();
2743
+ var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
2744
+ var targetGroupRow = groupRows[groupRowIndex];
2745
+
2746
+ if (!targetGroupRow) {
2747
+ return null;
2748
+ }
2749
+
2750
+ return targetGroupRow.querySelector("[col-id=\"" + escapeColumnIdSelector(groupId) + "\"]");
2751
+ };
2752
+
2753
+ var applyPivotRowGrandTotalGroupHeaderLabel = function applyPivotRowGrandTotalGroupHeaderLabel(gridRootElement, columnApi, measureCount, columnPivotFieldCount) {
2754
+ if (!gridRootElement || !columnApi || measureCount <= 1) {
2755
+ return;
2756
+ }
2757
+
2758
+ clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement);
2759
+ var displayedColumns = typeof columnApi.getAllDisplayedColumns === 'function' ? columnApi.getAllDisplayedColumns() : [];
2760
+ var rowGrandTotalColumns = displayedColumns.filter(function (column) {
2761
+ return String(column.getColId()).indexOf('PivotRowTotal_') === 0;
2762
+ });
2763
+
2764
+ if (rowGrandTotalColumns.length <= 1) {
2765
+ return;
2766
+ }
2767
+
2768
+ var centerHeaderContainer = gridRootElement.querySelector('.ag-header-viewport .ag-header-container');
2769
+
2770
+ if (!centerHeaderContainer) {
2771
+ return;
2772
+ }
2773
+
2774
+ var groupRows = Array.from(centerHeaderContainer.querySelectorAll('.ag-header-row-column-group'));
2775
+
2776
+ if (groupRows.length === 0) {
2777
+ return;
2778
+ }
2779
+
2780
+ var targetGroupLevel = columnPivotFieldCount > 0 ? columnPivotFieldCount - 1 : 0;
2781
+ var rowGrandTotalGroupCells = findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns);
2782
+
2783
+ if (rowGrandTotalGroupCells.length === 0) {
2784
+ return;
2785
+ }
2786
+
2787
+ applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells);
2788
+ };
2789
+
2790
+ var clearPivotRowGrandTotalGroupHeaderMarkup = function clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement) {
2791
+ gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header, .dl-pivot-row-grand-total-group-header-sibling').forEach(function (element) {
2792
+ element.classList.remove('dl-pivot-row-grand-total-group-header', 'dl-pivot-row-grand-total-group-header-sibling');
2793
+ });
2794
+ gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header-label').forEach(function (label) {
2795
+ label.classList.remove('dl-pivot-row-grand-total-group-header-label');
2796
+ var labelElement = label;
2797
+ labelElement.textContent = '';
2798
+ labelElement.style.width = '';
2799
+ labelElement.style.display = '';
2800
+ labelElement.style.textAlign = '';
2801
+ });
2802
+ };
2803
+
2804
+ var findRowGrandTotalGroupHeaderCells = function findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns) {
2805
+ var cellsByColumnGroup = [];
2806
+ rowGrandTotalColumns.forEach(function (column) {
2807
+ var columnGroup = getColumnGroupAtHeaderLevel(column, targetGroupLevel);
2808
+ var matchingCell = findHeaderGroupCellByColumnGroup(centerHeaderContainer, groupRows, targetGroupLevel, columnGroup);
2809
+
2810
+ if (matchingCell) {
2811
+ cellsByColumnGroup.push(matchingCell);
2812
+ }
2813
+ });
2814
+
2815
+ if (cellsByColumnGroup.length === rowGrandTotalColumns.length) {
2816
+ return cellsByColumnGroup;
2817
+ }
2818
+
2819
+ var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
2820
+ var targetGroupRow = groupRows[groupRowIndex];
2821
+
2822
+ if (!targetGroupRow) {
2823
+ return cellsByColumnGroup;
2824
+ }
2825
+
2826
+ var paddingCells = Array.from(targetGroupRow.querySelectorAll('.ag-header-group-cell-no-group'));
2827
+ var trailingPaddingCells = paddingCells.slice(-rowGrandTotalColumns.length);
2828
+
2829
+ if (trailingPaddingCells.length === rowGrandTotalColumns.length) {
2830
+ return trailingPaddingCells;
2831
+ }
2832
+
2833
+ return cellsByColumnGroup;
2834
+ };
2835
+
2836
+ var applyGrandTotalLabelToGroupHeaderCells = function applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells) {
2837
+ var firstCell = rowGrandTotalGroupCells[0];
2838
+ var firstLabel = firstCell.querySelector('.ag-header-group-text, .ag-header-cell-text');
2839
+
2840
+ if (!firstLabel) {
2841
+ return;
2842
+ }
2843
+
2844
+ var combinedWidth = rowGrandTotalGroupCells.reduce(function (totalWidth, cell) {
2845
+ return totalWidth + cell.offsetWidth;
2846
+ }, 0);
2847
+ firstLabel.textContent = 'Grand Total';
2848
+ firstLabel.style.width = combinedWidth + "px";
2849
+ firstLabel.style.display = 'inline-block';
2850
+ firstLabel.style.textAlign = 'center';
2851
+ firstLabel.classList.add('dl-pivot-row-grand-total-group-header-label');
2852
+ firstCell.classList.add('dl-pivot-row-grand-total-group-header');
2853
+
2854
+ for (var index = 1; index < rowGrandTotalGroupCells.length; index++) {
2855
+ rowGrandTotalGroupCells[index].classList.add('dl-pivot-row-grand-total-group-header-sibling');
2856
+ var siblingLabel = rowGrandTotalGroupCells[index].querySelector('.ag-header-group-text, .ag-header-cell-text');
2857
+
2858
+ if (siblingLabel) {
2859
+ siblingLabel.textContent = '';
2860
+ }
2861
+ }
2862
+ };
2863
+
2864
+ var applyPivotRowGrandTotalHeader = function applyPivotRowGrandTotalHeader(colDef, measureCount, measures) {
2865
+ if (!isPivotRowGrandTotalColumnDef(colDef)) {
2866
+ return;
2867
+ }
2868
+
2869
+ if (measureCount <= 1) {
2870
+ colDef.headerName = 'Grand Total';
2871
+ return;
2872
+ }
2873
+
2874
+ var measure = resolveMeasureFromPivotValueColumn(colDef, measures);
2875
+
2876
+ if (measure) {
2877
+ colDef.headerName = getMeasureCaption(measure);
2878
+ }
2879
+
2880
+ delete colDef.headerValueGetter;
2881
+ };
2882
+ var collectPivotRowPath = function collectPivotRowPath(startNode) {
2883
+ var path = [];
2884
+
2885
+ if (!startNode) {
2886
+ return path;
2887
+ }
2888
+
2889
+ if (startNode.footer) {
2890
+ if (startNode.level === -1) {
2891
+ return path;
2892
+ }
2893
+
2894
+ if (startNode.field != null && startNode.key !== undefined) {
2895
+ path.unshift({
2896
+ field: startNode.field,
2897
+ key: startNode.key
2898
+ });
2899
+ }
2900
+ }
2901
+
2902
+ var node = startNode.parent;
2903
+
2904
+ while (node && node.level >= 0) {
2905
+ if (!node.footer && node.field != null && node.key !== undefined) {
2906
+ path.unshift({
2907
+ field: node.field,
2908
+ key: node.key
2909
+ });
2910
+ }
2911
+
2912
+ node = node.parent;
2913
+ }
2914
+
2915
+ return path;
2916
+ };
2917
+ var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(colDef, startNode, apiFields) {
2918
+ var columnFields = apiFields.filter(function (field) {
2919
+ return !isRowPivotField(field);
2920
+ });
2921
+ var rowFields = apiFields.filter(isRowPivotField);
2922
+ var pivotFields = [];
2923
+ var columnKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
2924
+ columnKeys.forEach(function (key, index) {
2925
+ if (key === undefined) {
2926
+ return;
2927
+ }
2928
+
2929
+ var field = columnFields[index];
2930
+
2931
+ if (!field) {
2932
+ return;
2933
+ }
2934
+
2935
+ pivotFields.push({
2936
+ FieldId: field.FieldId,
2937
+ FieldType: field.FieldType ? field.FieldType : 'Field',
2938
+ FieldValue: key,
2939
+ DateCode: field.DateCode
2940
+ });
2941
+ });
2942
+ collectPivotRowPath(startNode).forEach(function (pathItem) {
2943
+ var field = rowFields.find(function (f) {
2944
+ return f.PivotCode === pathItem.field;
2945
+ }) || apiFields.find(function (f) {
2946
+ return f.PivotCode === pathItem.field;
2947
+ });
2948
+
2949
+ if (!field) {
2950
+ return;
2951
+ }
2952
+
2953
+ pivotFields.push({
2954
+ FieldId: field.FieldId,
2955
+ FieldType: field.FieldType ? field.FieldType : 'Field',
2956
+ FieldValue: pathItem.key,
2957
+ DateCode: field.DateCode
2958
+ });
2959
+ });
2960
+ return pivotFields;
2961
+ };
2962
+ var getMeasureCaption = function getMeasureCaption(measure) {
2963
+ var displayName = typeof measure.DisplayName == 'string' ? measure.DisplayName : '';
2964
+
2965
+ if (measure.MeasureCode == 'Sum') {
2966
+ return ConvertStringToPascalCaseHelper(displayName.replace('Sum of ', ''));
2967
+ }
2968
+
2969
+ return ConvertStringToPascalCaseHelper(displayName);
2970
+ };
2971
+ var parseJsonArray = function parseJsonArray(json) {
2972
+ if (isNullOrUndefinedOrEmpty(json)) return [];
2973
+
2974
+ try {
2975
+ var parsed = JSON.parse(json);
2976
+ return parsed || [];
2977
+ } catch (error) {
2978
+ return [];
2979
+ }
2980
+ };
2981
+ var parsePivotTotalsSettings = function parsePivotTotalsSettings(json) {
2982
+ if (isNullOrUndefinedOrEmpty(json)) return {};
2983
+
2984
+ try {
2985
+ return JSON.parse(json) || {};
2986
+ } catch (error) {
2987
+ return {};
2988
+ }
2989
+ };
2990
+
2991
+ var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
2992
+
2993
+ var applyAgGridLicense = function applyAgGridLicense() {
2994
+ if (!Session.AgGridLicenseKey) return;
2995
+ LicenseManager.setLicenseKey(Session.AgGridLicenseKey);
2996
+ };
2997
+
2998
+ var AgPivotGrid = forwardRef(function (props, _comRef) {
2999
+ var _useState = useState(),
3000
+ widget = _useState[0],
3001
+ setWidget = _useState[1];
3002
+
3003
+ var _useState2 = useState(true),
3004
+ isLoading = _useState2[0],
3005
+ setIsLoading = _useState2[1];
3006
+
3007
+ var _useState3 = useState([]),
3008
+ rowData = _useState3[0],
3009
+ setRowData = _useState3[1];
3010
+
3011
+ var _useState4 = useState([]),
3012
+ columnDefs = _useState4[0],
3013
+ setColumnDefs = _useState4[1];
3014
+
3015
+ var _useState5 = useState(0),
3016
+ measureCount = _useState5[0],
3017
+ setMeasureCount = _useState5[1];
3018
+
3019
+ var widgetRefData = useRef(null);
3020
+ var tabledata = useRef();
3021
+ var gridApiRef = useRef(null);
3022
+ var columnApiRef = useRef(null);
3023
+ var gridContainerRef = useRef(null);
3024
+ var pivotFieldsRef = useRef([]);
3025
+ var pivotMeasuresRef = useRef([]);
3026
+ useEffect(function () {
3027
+ var _props$customChartPro;
3028
+
3029
+ applyAgGridLicense();
3030
+
3031
+ if (props.customChartProps && props.customChartProps.widget) {
3032
+ setWidget(props.customChartProps.widget);
3033
+ widgetRefData.current = props.customChartProps.widget;
3034
+ getPivotTableData(props.customChartProps.widget);
3035
+ }
3036
+
3037
+ (_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
3038
+ var _widgetRefData$curren;
3039
+
3040
+ 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;
3041
+ setWidget(_extends({}, updatedWidget));
3042
+ });
3043
+ document.addEventListener('resizeStop', handleResize);
3044
+ return function () {
3045
+ document.removeEventListener('resizeStop', handleResize);
3046
+ };
3047
+ }, []);
3048
+ useEffect(function () {
3049
+ if (!props.customChartProps.isInEditMode) return;
3050
+
3051
+ if (gridContainerRef.current && gridContainerRef.current.classList) {
3052
+ gridContainerRef.current.classList.add('force-overflow-hidden');
3053
+ }
3054
+
3055
+ setTimeout(function () {
3056
+ handleResize();
3057
+
3058
+ if (gridContainerRef.current && gridContainerRef.current.classList) {
3059
+ gridContainerRef.current.classList.remove('force-overflow-hidden');
3060
+ }
3061
+ }, 5);
3062
+ }, [props.customChartProps.isInEditMode]);
3063
+
3064
+ var handleResize = function handleResize() {
3065
+ if (gridApiRef.current && gridApiRef.current.resetRowHeights) {
3066
+ gridApiRef.current.resetRowHeights();
3067
+ }
3068
+ };
3069
+
3070
+ var getPivotTableData = function getPivotTableData(widgetPm) {
3071
+ if (Session.Tenant == 0) {
3072
+ tabledata.current = [];
3073
+ setRowData([]);
3074
+ setIsLoading(false);
3075
+ return;
3076
+ }
3077
+
3078
+ var dashboardAnalyticsService = new DashboardAnalyticsService();
3079
+ var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, 'PostGetPivotData');
3080
+ dashboardAnalyticsService.getPivotData(widgetPm).then(function (res) {
3081
+ tabledata.current = res.data;
3082
+ buildGridFromPivotResponse();
3083
+ setIsLoading(false);
3084
+ widgetLoadLogger.log(res);
3085
+ })["catch"](function (err) {
3086
+ console.log('Error while Getting Pivot Table Data: ', err);
3087
+ tabledata.current = null;
3088
+ setRowData([]);
3089
+ setIsLoading(false);
3090
+ });
3091
+ };
3092
+
3093
+ var lookupDisplayName = function lookupDisplayName(field, rawValue) {
3094
+ var pivotData = tabledata.current && tabledata.current.PivotData ? tabledata.current.PivotData : [];
3095
+ return getPivotDisplayName(pivotData, field.PivotName, field.PivotCode, rawValue);
3096
+ };
3097
+
3098
+ var lookupDisplayNameByFieldCode = function lookupDisplayNameByFieldCode(fieldCode, rawValue) {
3099
+ var field = pivotFieldsRef.current.find(function (f) {
3100
+ return f.PivotCode === fieldCode;
3101
+ });
3102
+ if (!field) return rawValue == null ? '' : String(rawValue);
3103
+ return lookupDisplayName(field, rawValue);
3104
+ };
3105
+
3106
+ var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef) {
3107
+ colDef.sortable = false;
3108
+ colDef.filter = false;
3109
+ colDef.cellClass = 'dl-ag-pivot-data-cell';
3110
+ colDef.type = 'numericColumn';
3111
+ };
3112
+
3113
+ var buildGridFromPivotResponse = function buildGridFromPivotResponse() {
3114
+ if (!tabledata.current || !tabledata.current.PivoFields || !tabledata.current.PivotMeasures) {
3115
+ setRowData([]);
3116
+ return;
3117
+ }
3118
+
3119
+ var apiFields = tabledata.current.PivoFields;
3120
+ var apiMeasures = tabledata.current.PivotMeasures;
3121
+ pivotFieldsRef.current = apiFields;
3122
+ pivotMeasuresRef.current = apiMeasures;
3123
+ setMeasureCount(apiMeasures.length);
3124
+ var rowFields = apiFields.filter(isRowPivotField);
3125
+ var columnFields = apiFields.filter(function (field) {
3126
+ return !isRowPivotField(field);
3127
+ });
3128
+ var defs = [];
3129
+ rowFields.forEach(function (field, index) {
3130
+ defs.push(createRowGroupColDef(field, index));
3131
+ });
3132
+ columnFields.forEach(function (field, index) {
3133
+ defs.push(createPivotColDef(field, index));
3134
+ });
3135
+ apiMeasures.forEach(function (measure) {
3136
+ defs.push(createMeasureColDef(measure));
3137
+ });
3138
+ setColumnDefs(defs);
3139
+ setRowData(tabledata.current.PivotData || []);
3140
+ };
3141
+
3142
+ var createRowGroupColDef = function createRowGroupColDef(field, index) {
3143
+ return {
3144
+ field: field.PivotCode,
3145
+ headerName: field.DisplayName,
3146
+ rowGroup: true,
3147
+ rowGroupIndex: index,
3148
+ enableRowGroup: true,
3149
+ hide: true,
3150
+ width: ROW_GROUP_COLUMN_MIN_WIDTH,
3151
+ wrapText: true,
3152
+ autoHeight: true,
3153
+ sortable: false,
3154
+ filter: false,
3155
+ comparator: function comparator(a, b) {
3156
+ return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
3157
+ },
3158
+ valueFormatter: function valueFormatter(params) {
3159
+ return lookupDisplayName(field, params.value);
3160
+ }
3161
+ };
3162
+ };
3163
+
3164
+ var createPivotColDef = function createPivotColDef(field, index) {
3165
+ return {
3166
+ field: field.PivotCode,
3167
+ headerName: field.DisplayName,
3168
+ pivot: true,
3169
+ pivotIndex: index,
3170
+ enablePivot: true,
3171
+ hide: true,
3172
+ sortable: false,
3173
+ filter: false,
3174
+ pivotComparator: function pivotComparator(a, b) {
3175
+ return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
3176
+ }
3177
+ };
3178
+ };
3179
+
3180
+ var createMeasureColDef = function createMeasureColDef(measure) {
3181
+ return {
3182
+ field: measure.PivotMeasureCode,
3183
+ headerName: getMeasureCaption(measure),
3184
+ aggFunc: 'logitudeSum',
3185
+ enableValue: true,
3186
+ wrapText: true,
3187
+ autoHeight: true,
3188
+ sortable: false,
3189
+ filter: false,
3190
+ cellClass: 'dl-ag-pivot-data-cell',
3191
+ type: 'numericColumn',
3192
+ valueFormatter: function valueFormatter(params) {
3193
+ return formatPivotMeasureValue(params.value, measure);
3194
+ }
3195
+ };
3196
+ };
3197
+
3198
+ var isRowsEmptyAndColumnsNotEmpty = function isRowsEmptyAndColumnsNotEmpty() {
3199
+ var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
3200
+ var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
3201
+ return pivotRows.length === 0 && pivotColumns.length > 0;
3202
+ };
3203
+
3204
+ var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
3205
+ var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
3206
+ var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
3207
+ return pivotRows.length > 0 && pivotColumns.length === 0;
3208
+ };
3209
+
3210
+ var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
3211
+ if (isRowsEmptyAndColumnsNotEmpty()) return true;
3212
+ var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3213
+ return !isNullOrUndefinedOrEmpty(settings.ShowRowsGrandTotal) ? !!settings.ShowRowsGrandTotal : false;
3214
+ };
3215
+
3216
+ var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
3217
+ if (isRowsNotEmptyAndColumnsEmpty()) return true;
3218
+ var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3219
+ return !isNullOrUndefinedOrEmpty(settings.ShowColumnsGrandTotal) ? !!settings.ShowColumnsGrandTotal : false;
3220
+ };
3221
+
3222
+ var canShowRowsTotal = function canShowRowsTotal() {
3223
+ var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3224
+ return !isNullOrUndefinedOrEmpty(settings.ShowRowsTotal) ? !!settings.ShowRowsTotal : false;
3225
+ };
3226
+
3227
+ var canShowColumnsTotal = function canShowColumnsTotal() {
3228
+ var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3229
+ return !isNullOrUndefinedOrEmpty(settings.ShowColumnsTotal) ? !!settings.ShowColumnsTotal : false;
3230
+ };
3231
+
3232
+ var isSingleMeasurePivot = measureCount <= 1;
3233
+ var processSecondaryColGroupDef = useCallback(function (colGroupDef) {
3234
+ var columnFields = pivotFieldsRef.current.filter(function (field) {
3235
+ return !isRowPivotField(field);
3236
+ });
3237
+ var headerName = resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName);
3238
+
3239
+ if (headerName) {
3240
+ colGroupDef.headerName = headerName;
3241
+ }
3242
+ }, []);
3243
+ var processSecondaryColDef = useCallback(function (colDef) {
3244
+ var columnFields = pivotFieldsRef.current.filter(function (field) {
3245
+ return !isRowPivotField(field);
3246
+ });
3247
+ var colDefAny = colDef;
3248
+
3249
+ if (colDefAny.colId && String(colDefAny.colId).indexOf('PivotRowTotal_') === 0) {
3250
+ applyPivotRowGrandTotalHeader(colDefAny, pivotMeasuresRef.current.length, pivotMeasuresRef.current);
3251
+ } else {
3252
+ var headerName = resolvePivotLeafHeaderName(colDefAny, columnFields, lookupDisplayName, pivotMeasuresRef.current.length);
3253
+
3254
+ if (headerName) {
3255
+ colDef.headerName = headerName;
3256
+ }
3257
+ }
3258
+
3259
+ applyPivotDataCellFormatting(colDef);
3260
+
3261
+ colDef.valueFormatter = function (params) {
3262
+ var measure = resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
3263
+ if (!measure) return '';
3264
+ return formatPivotMeasureValue(params.value, measure);
3265
+ };
3266
+ }, []);
3267
+ var onCellClicked = useCallback(function (event) {
3268
+ var colDef = event.colDef;
3269
+ if (!colDef || !colDef.pivotValueColumn) return;
3270
+ if (isPivotMeasureValueEmpty(event.value)) return;
3271
+ var pivotFields = buildPivotDrillDownPivotFields(colDef, event.node, pivotFieldsRef.current);
3272
+ props.customChartProps.onSelectDataPoint({
3273
+ MeasureFieldId: '',
3274
+ MeasureFieldType: '',
3275
+ Widget: props.customChartProps.widget,
3276
+ MeasureCode: '',
3277
+ Formula: '',
3278
+ GroupById: '',
3279
+ PivotFields: pivotFields
3280
+ });
3281
+ }, []);
3282
+ var defaultColDef = useMemo(function () {
3283
+ return {
3284
+ sortable: false,
3285
+ filter: false,
3286
+ resizable: false,
3287
+ suppressMenu: true,
3288
+ wrapText: true,
3289
+ autoHeight: true
3290
+ };
3291
+ }, []);
3292
+ var autoGroupColumnDef = useMemo(function () {
3293
+ return {
3294
+ minWidth: ROW_GROUP_COLUMN_MIN_WIDTH,
3295
+ width: ROW_GROUP_COLUMN_MIN_WIDTH,
3296
+ sortable: false,
3297
+ filter: false,
3298
+ wrapText: true,
3299
+ autoHeight: true,
3300
+ cellClass: 'dl-ag-pivot-row-label-cell',
3301
+ headerValueGetter: function headerValueGetter(params) {
3302
+ var colDef = params.colDef;
3303
+ var showRowGroup = colDef && colDef.showRowGroup;
3304
+ if (!showRowGroup) return '';
3305
+ var field = pivotFieldsRef.current.find(function (f) {
3306
+ return f.PivotCode === showRowGroup;
3307
+ });
3308
+ return field ? field.DisplayName : '';
3309
+ },
3310
+ valueFormatter: function valueFormatter(params) {
3311
+ var colDef = params.colDef;
3312
+ var showRowGroup = colDef && colDef.showRowGroup;
3313
+ var field = pivotFieldsRef.current.find(function (f) {
3314
+ return f.PivotCode === showRowGroup;
3315
+ });
3316
+ if (!field) return params.value == null ? '' : String(params.value);
3317
+ return lookupDisplayName(field, params.value);
3318
+ },
3319
+ cellRendererParams: {
3320
+ suppressCount: true,
3321
+ footerValueGetter: function footerValueGetter(params) {
3322
+ var fieldCode = params.node && params.node.field ? params.node.field : params.colDef && params.colDef.showRowGroup ? params.colDef.showRowGroup : null;
3323
+ return getPivotGroupFooterLabel(params.node, fieldCode, params.value, lookupDisplayNameByFieldCode);
3324
+ }
3325
+ }
3326
+ };
3327
+ }, []);
3328
+ var aggFuncs = useMemo(function () {
3329
+ return {
3330
+ logitudeSum: logitudeSumAgg
3331
+ };
3332
+ }, []);
3333
+ var scheduleRowGrandTotalHeaderLabel = useCallback(function () {
3334
+ var columnPivotFieldCount = pivotFieldsRef.current.filter(function (field) {
3335
+ return !isRowPivotField(field);
3336
+ }).length;
3337
+
3338
+ var applyLabel = function applyLabel() {
3339
+ applyPivotRowGrandTotalGroupHeaderLabel(gridContainerRef.current, columnApiRef.current, measureCount, columnPivotFieldCount);
3340
+ };
3341
+
3342
+ window.requestAnimationFrame(function () {
3343
+ window.requestAnimationFrame(function () {
3344
+ applyLabel();
3345
+ window.setTimeout(applyLabel, 150);
3346
+ });
3347
+ });
3348
+ }, [measureCount]);
3349
+
3350
+ var onGridReady = function onGridReady(event) {
3351
+ gridApiRef.current = event.api;
3352
+ columnApiRef.current = event.columnApi;
3353
+ };
3354
+
3355
+ var onFirstDataRendered = function onFirstDataRendered(event) {
3356
+ columnApiRef.current = event.columnApi;
3357
+ var columnApi = event.columnApi;
3358
+ if (!columnApi || !columnApi.getAllDisplayedColumns) return;
3359
+ var autoGroupColumnIds = columnApi.getAllDisplayedColumns().map(function (col) {
3360
+ return col.getColId();
3361
+ }).filter(function (colId) {
3362
+ return colId.indexOf('ag-Grid-AutoColumn') === 0;
3363
+ });
3364
+
3365
+ if (autoGroupColumnIds.length > 0 && columnApi.autoSizeColumns) {
3366
+ columnApi.autoSizeColumns(autoGroupColumnIds, false);
3367
+ }
3368
+
3369
+ scheduleRowGrandTotalHeaderLabel();
3370
+ };
3371
+
3372
+ var onColumnPivotChanged = function onColumnPivotChanged() {
3373
+ scheduleRowGrandTotalHeaderLabel();
3374
+ };
3375
+
3376
+ var onColumnResized = function onColumnResized() {
3377
+ scheduleRowGrandTotalHeaderLabel();
3378
+ };
3379
+
3380
+ var gridWrapperClassName = 'ag-theme-balham pivot-grid-element dl-ag-pivot-grid';
3381
+ return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
3382
+ className: 'dl-full-hight dl-flex-content-center spinner-custome'
3383
+ }, React__default.createElement(ProgressSpinner, {
3384
+ style: {
3385
+ width: '40px',
3386
+ height: '40px'
3387
+ },
3388
+ strokeWidth: "4",
3389
+ animationDuration: "2s"
3390
+ })) : React__default.createElement("div", {
3391
+ ref: gridContainerRef,
3392
+ className: gridWrapperClassName
3393
+ }, React__default.createElement(AgGridReact, {
3394
+ rowData: rowData,
3395
+ columnDefs: columnDefs,
3396
+ defaultColDef: defaultColDef,
3397
+ autoGroupColumnDef: autoGroupColumnDef,
3398
+ aggFuncs: aggFuncs,
3399
+ pivotMode: true,
3400
+ groupDisplayType: "multipleColumns",
3401
+ groupDefaultExpanded: -1,
3402
+ suppressAggFuncInHeader: true,
3403
+ removePivotHeaderRowWhenSingleValueColumn: isSingleMeasurePivot,
3404
+ groupIncludeFooter: canShowRowsTotal(),
3405
+ groupIncludeTotalFooter: canShowRowsGrandTotal(),
3406
+ pivotRowTotals: canShowColumnsGrandTotal() ? 'after' : undefined,
3407
+ pivotColumnGroupTotals: canShowColumnsTotal() ? 'after' : undefined,
3408
+ processSecondaryColGroupDef: processSecondaryColGroupDef,
3409
+ processSecondaryColDef: processSecondaryColDef,
3410
+ onCellClicked: onCellClicked,
3411
+ onGridReady: onGridReady,
3412
+ onFirstDataRendered: onFirstDataRendered,
3413
+ onColumnPivotChanged: onColumnPivotChanged,
3414
+ onColumnResized: onColumnResized,
3415
+ animateRows: false,
3416
+ suppressContextMenu: true,
3417
+ suppressMovableColumns: true,
3418
+ headerHeight: 36,
3419
+ rowHeight: 36
3420
+ })));
3421
+ });
3422
+
2372
3423
  var parseSelectedQueries = function parseSelectedQueries(widgetJson) {
2373
3424
  if (!widgetJson) {
2374
3425
  return [];
@@ -2449,7 +3500,9 @@ var CustomChart = function CustomChart(props) {
2449
3500
  });
2450
3501
 
2451
3502
  case "pivot":
2452
- return React__default.createElement(PivotTable, {
3503
+ return props.useAgGridPivot ? React__default.createElement(AgPivotGrid, {
3504
+ customChartProps: props
3505
+ }) : React__default.createElement(PivotTable, {
2453
3506
  customChartProps: props
2454
3507
  });
2455
3508
 
@@ -4292,6 +5345,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4292
5345
  if (((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "kpi") return React__default.createElement(CustomChart, {
4293
5346
  isInEditMode: props.isInEditMode,
4294
5347
  isPreviewModeActive: props.isPreviewModeActive,
5348
+ useAgGridPivot: props.useAgGridPivot,
4295
5349
  dataBinding: props.dataBinding,
4296
5350
  widget: widget.current,
4297
5351
  widgetRef: props.widgetRef,
@@ -4303,6 +5357,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4303
5357
  if (((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.TypeCode) == "table" || ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.TypeCode) == "pivot" || ((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.TypeCode) == "views") return React__default.createElement(CustomChart, {
4304
5358
  isInEditMode: props.isInEditMode,
4305
5359
  isPreviewModeActive: props.isPreviewModeActive,
5360
+ useAgGridPivot: props.useAgGridPivot,
4306
5361
  dataBinding: props.dataBinding,
4307
5362
  widget: widget.current,
4308
5363
  widgetRef: props.widgetRef,
@@ -4747,6 +5802,7 @@ var DashboardDesigner = function DashboardDesigner(props) {
4747
5802
  editBtnClicked: editWidget,
4748
5803
  deleteBtnClicked: confirmDeleteWidget,
4749
5804
  onSelectDataPoint: props.onSelectDataPoint,
5805
+ useAgGridPivot: props.useAgGridPivot,
4750
5806
  duplicateBtnClicked: copyWidget,
4751
5807
  copyToClipboardBtnClicked: copyWidgetToClipboard,
4752
5808
  ref: function ref(el) {
@@ -4777,6 +5833,8 @@ var layoutGridProps = {
4777
5833
  var Dashboard = function Dashboard(props) {
4778
5834
  var _previewWidget$Layout, _previewWidget$Layout2;
4779
5835
 
5836
+ Session.UseAgGridPivot = !!props.useAgGridPivot;
5837
+ Session.AgGridLicenseKey = props.agGridLicenseKey;
4780
5838
  var Widgetlayouts = useRef({
4781
5839
  lg: []
4782
5840
  });
@@ -4805,6 +5863,8 @@ var Dashboard = function Dashboard(props) {
4805
5863
  Session.Token = props === null || props === void 0 ? void 0 : props.token;
4806
5864
  Session.NumberFormatCode = props === null || props === void 0 ? void 0 : props.numberFormatCode;
4807
5865
  Session.isMasterNumberClickable = props === null || props === void 0 ? void 0 : props.isMasterNumberClickable;
5866
+ Session.UseAgGridPivot = !!props.useAgGridPivot;
5867
+ Session.AgGridLicenseKey = props.agGridLicenseKey;
4808
5868
  setIsPreviewModeActive(props.isPreviewMode);
4809
5869
  props.dataBinding.onGetLayouts.subscribe(function (layouts) {
4810
5870
  Widgetlayouts.current = layouts;
@@ -4818,6 +5878,10 @@ var Dashboard = function Dashboard(props) {
4818
5878
  setWidgetlayoutsState(deepClone(Widgetlayouts.current));
4819
5879
  });
4820
5880
  }, []);
5881
+ useEffect(function () {
5882
+ Session.UseAgGridPivot = !!props.useAgGridPivot;
5883
+ Session.AgGridLicenseKey = props.agGridLicenseKey;
5884
+ }, [props.useAgGridPivot, props.agGridLicenseKey]);
4821
5885
  useEffect(function () {
4822
5886
  if (props.widgetData) {
4823
5887
  setPreviewWidget(JSON.parse(JSON.stringify(props.widgetData)));
@@ -4888,13 +5952,15 @@ var Dashboard = function Dashboard(props) {
4888
5952
  },
4889
5953
  onSelectDataPoint: function onSelectDataPoint() {
4890
5954
  return true;
4891
- }
5955
+ },
5956
+ useAgGridPivot: props.useAgGridPivot
4892
5957
  }))) : createElement("div", {
4893
5958
  className: 'dl-full-hight'
4894
5959
  }, createElement("div", {
4895
5960
  className: 'dl-dashboard-body'
4896
5961
  }, createElement(DashboardDesigner, {
4897
5962
  onSelectDataPoint: props.onSelectDataPoint,
5963
+ useAgGridPivot: props.useAgGridPivot,
4898
5964
  Widgetlayouts: widgetlayoutsState,
4899
5965
  dataBinding: props.dataBinding,
4900
5966
  editMode: isInEditMode,