logitude-dashboard-library 3.2.62 → 3.2.63
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/assets/styles/dl-dashboard.scss +107 -1
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/AgPivotGrid.d.ts +10 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/CustomChart.d.ts +1 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/PivotAgGridSupport.d.ts +45 -0
- package/dist/features/Dashboard/DashboardDesigner.d.ts +1 -0
- package/dist/features/Dashboard/WidgetCard.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +959 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +959 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/services/session.d.ts +2 -0
- package/dist/styles/dl-dashboard.scss +107 -1
- package/package.json +8 -2
package/dist/index.js
CHANGED
|
@@ -12,6 +12,10 @@ var column = require('primereact/column');
|
|
|
12
12
|
var PivotGrid = require('devextreme-react/pivot-grid');
|
|
13
13
|
var PivotGrid__default = _interopDefault(PivotGrid);
|
|
14
14
|
var PivotGridDataSource = _interopDefault(require('devextreme/ui/pivot_grid/data_source'));
|
|
15
|
+
var agGridReact = require('ag-grid-react');
|
|
16
|
+
var agGridEnterprise = require('ag-grid-enterprise');
|
|
17
|
+
require('ag-grid-community/dist/styles/ag-grid.css');
|
|
18
|
+
require('ag-grid-community/dist/styles/ag-theme-balham.css');
|
|
15
19
|
var ReactFC = _interopDefault(require('react-fusioncharts'));
|
|
16
20
|
var FusionCharts = _interopDefault(require('fusioncharts'));
|
|
17
21
|
var Charts = _interopDefault(require('fusioncharts/fusioncharts.charts'));
|
|
@@ -81,6 +85,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
var Session = function Session() {};
|
|
88
|
+
Session.UseAgGridPivot = false;
|
|
84
89
|
|
|
85
90
|
var Tools = /*#__PURE__*/function () {
|
|
86
91
|
function Tools() {}
|
|
@@ -2373,6 +2378,943 @@ var PivotTable = React.forwardRef(function (props, comRef) {
|
|
|
2373
2378
|
})));
|
|
2374
2379
|
});
|
|
2375
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
|
+
}
|
|
2406
|
+
|
|
2407
|
+
return hasValue ? total : null;
|
|
2408
|
+
};
|
|
2409
|
+
var formatPivotMeasureValue = function formatPivotMeasureValue(value, measure) {
|
|
2410
|
+
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2411
|
+
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2412
|
+
var minimumFraction = isInteger ? 0 : 2;
|
|
2413
|
+
return getNumberInSystemLocalFormat(value, 2, minimumFraction);
|
|
2414
|
+
};
|
|
2415
|
+
var getPivotGroupFooterLabel = function getPivotGroupFooterLabel(node, fieldCode, rawValue, lookupDisplayName) {
|
|
2416
|
+
if (!node || !node.footer) return '';
|
|
2417
|
+
|
|
2418
|
+
if (node.level === -1) {
|
|
2419
|
+
return 'Grand Total';
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
if (!fieldCode) return '';
|
|
2423
|
+
var displayName = lookupDisplayName(fieldCode, rawValue);
|
|
2424
|
+
return displayName ? displayName + " Total" : '';
|
|
2425
|
+
};
|
|
2426
|
+
var compareDimensionValues = function compareDimensionValues(aValue, bValue, dateCode, aText, bText) {
|
|
2427
|
+
if (dateCode === 'Month') {
|
|
2428
|
+
var aNumber = aValue == null ? -1 : Number(aValue);
|
|
2429
|
+
var bNumber = bValue == null ? -1 : Number(bValue);
|
|
2430
|
+
if (aNumber < bNumber) return -1;
|
|
2431
|
+
if (aNumber > bNumber) return 1;
|
|
2432
|
+
return 0;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
if (dateCode != null) {
|
|
2436
|
+
var aCompare = aValue == null ? '' : aValue;
|
|
2437
|
+
var bCompare = bValue == null ? '' : bValue;
|
|
2438
|
+
if (aCompare < bCompare) return -1;
|
|
2439
|
+
if (aCompare > bCompare) return 1;
|
|
2440
|
+
return 0;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
var aDisplay = aText == null || aText === '' ? aValue == null ? '' : aValue : aText;
|
|
2444
|
+
var bDisplay = bText == null || bText === '' ? bValue == null ? '' : bValue : bText;
|
|
2445
|
+
if (aDisplay < bDisplay) return -1;
|
|
2446
|
+
if (aDisplay > bDisplay) return 1;
|
|
2447
|
+
return 0;
|
|
2448
|
+
};
|
|
2449
|
+
var getPivotDisplayName = function getPivotDisplayName(pivotData, fieldName, dataField, dataFieldValue) {
|
|
2450
|
+
if (!pivotData || pivotData.length === 0) return '';
|
|
2451
|
+
var data = pivotData.find(function (el) {
|
|
2452
|
+
return el[dataField] == dataFieldValue;
|
|
2453
|
+
});
|
|
2454
|
+
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2455
|
+
};
|
|
2456
|
+
var isPivotRowGrandTotalColumnDef = function isPivotRowGrandTotalColumnDef(colDef) {
|
|
2457
|
+
if (!colDef || !colDef.colId) {
|
|
2458
|
+
return false;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
return String(colDef.colId).indexOf('PivotRowTotal_') === 0;
|
|
2462
|
+
};
|
|
2463
|
+
var isPivotRowGrandTotalGroupDef = function isPivotRowGrandTotalGroupDef(colGroupDef) {
|
|
2464
|
+
if (!colGroupDef) {
|
|
2465
|
+
return false;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
var groupId = colGroupDef.groupId || colGroupDef.colId || '';
|
|
2469
|
+
|
|
2470
|
+
if (String(groupId).indexOf('PivotRowTotal') >= 0) {
|
|
2471
|
+
return true;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
var children = colGroupDef.children;
|
|
2475
|
+
|
|
2476
|
+
if (!children || children.length === 0) {
|
|
2477
|
+
return false;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
return children.every(function (child) {
|
|
2481
|
+
if (child && child.children) {
|
|
2482
|
+
return isPivotRowGrandTotalGroupDef(child);
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
return isPivotRowGrandTotalColumnDef(child);
|
|
2486
|
+
});
|
|
2487
|
+
};
|
|
2488
|
+
var resolvePivotGroupHeaderName = function resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName) {
|
|
2489
|
+
if (isPivotRowGrandTotalGroupDef(colGroupDef)) {
|
|
2490
|
+
return 'Grand Total';
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
var pivotKeys = colGroupDef && colGroupDef.pivotKeys ? colGroupDef.pivotKeys : [];
|
|
2494
|
+
|
|
2495
|
+
if (pivotKeys.length === 0) {
|
|
2496
|
+
return null;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
var field = columnFields[pivotKeys.length - 1];
|
|
2500
|
+
|
|
2501
|
+
if (!field) {
|
|
2502
|
+
return null;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
|
|
2506
|
+
};
|
|
2507
|
+
var getPivotValueColumnId = function getPivotValueColumnId(pivotValueColumn) {
|
|
2508
|
+
if (!pivotValueColumn) {
|
|
2509
|
+
return null;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
if (typeof pivotValueColumn.getId === 'function') {
|
|
2513
|
+
return pivotValueColumn.getId();
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
if (typeof pivotValueColumn.getColId === 'function') {
|
|
2517
|
+
return pivotValueColumn.getColId();
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
if (pivotValueColumn.colId) {
|
|
2521
|
+
return String(pivotValueColumn.colId);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
if (pivotValueColumn.field) {
|
|
2525
|
+
return String(pivotValueColumn.field);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
return null;
|
|
2529
|
+
};
|
|
2530
|
+
var resolveMeasureFromPivotValueColumn = function resolveMeasureFromPivotValueColumn(colDef, measures) {
|
|
2531
|
+
if (!colDef || measures.length === 0) {
|
|
2532
|
+
return undefined;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
if (measures.length === 1) {
|
|
2536
|
+
return measures[0];
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
var valueColumnId = getPivotValueColumnId(colDef.pivotValueColumn);
|
|
2540
|
+
|
|
2541
|
+
if (valueColumnId) {
|
|
2542
|
+
var measureByValueColumn = measures.find(function (measure) {
|
|
2543
|
+
return measure.PivotMeasureCode === valueColumnId;
|
|
2544
|
+
});
|
|
2545
|
+
|
|
2546
|
+
if (measureByValueColumn) {
|
|
2547
|
+
return measureByValueColumn;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
var colId = colDef.colId ? String(colDef.colId) : '';
|
|
2552
|
+
|
|
2553
|
+
if (colId) {
|
|
2554
|
+
var sortedMeasures = [].concat(measures).sort(function (left, right) {
|
|
2555
|
+
return right.PivotMeasureCode.length - left.PivotMeasureCode.length;
|
|
2556
|
+
});
|
|
2557
|
+
|
|
2558
|
+
for (var index = 0; index < sortedMeasures.length; index++) {
|
|
2559
|
+
var measureCode = sortedMeasures[index].PivotMeasureCode;
|
|
2560
|
+
|
|
2561
|
+
if (colId.endsWith('_' + measureCode)) {
|
|
2562
|
+
return sortedMeasures[index];
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
return undefined;
|
|
2568
|
+
};
|
|
2569
|
+
var resolvePivotLeafHeaderName = function resolvePivotLeafHeaderName(colDef, columnFields, lookupDisplayName, measureCount, measures) {
|
|
2570
|
+
if (isPivotRowGrandTotalColumnDef(colDef)) {
|
|
2571
|
+
return null;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
if (measureCount > 1 && colDef.pivotValueColumn) {
|
|
2575
|
+
return null;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
var pivotKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
|
|
2579
|
+
|
|
2580
|
+
if (pivotKeys.length === 0) {
|
|
2581
|
+
return null;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
var field = columnFields[pivotKeys.length - 1];
|
|
2585
|
+
|
|
2586
|
+
if (!field) {
|
|
2587
|
+
return null;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
|
|
2591
|
+
};
|
|
2592
|
+
var resolveMeasureForSecondaryColDef = function resolveMeasureForSecondaryColDef(colDef, measures) {
|
|
2593
|
+
return resolveMeasureFromPivotValueColumn(colDef, measures);
|
|
2594
|
+
};
|
|
2595
|
+
|
|
2596
|
+
var getColumnGroupAtHeaderLevel = function getColumnGroupAtHeaderLevel(column, targetLevel) {
|
|
2597
|
+
if (!column || typeof column.getParent !== 'function') {
|
|
2598
|
+
return null;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
var groupPointer = column.getParent();
|
|
2602
|
+
|
|
2603
|
+
while (groupPointer) {
|
|
2604
|
+
var providedColumnGroup = typeof groupPointer.getProvidedColumnGroup === 'function' ? groupPointer.getProvidedColumnGroup() : null;
|
|
2605
|
+
|
|
2606
|
+
if (!providedColumnGroup) {
|
|
2607
|
+
groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
|
|
2608
|
+
continue;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
var originalGroupLevel = typeof providedColumnGroup.getLevel === 'function' ? providedColumnGroup.getLevel() : 0;
|
|
2612
|
+
var groupPointerLevel = typeof groupPointer.getPaddingLevel === 'function' ? groupPointer.getPaddingLevel() : 0;
|
|
2613
|
+
|
|
2614
|
+
if (originalGroupLevel + groupPointerLevel <= targetLevel) {
|
|
2615
|
+
return groupPointer;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
return null;
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2624
|
+
var escapeColumnIdSelector = function escapeColumnIdSelector(columnId) {
|
|
2625
|
+
if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {
|
|
2626
|
+
return CSS.escape(columnId);
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
return columnId.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
var findHeaderGroupCellByColumnGroup = function findHeaderGroupCellByColumnGroup(headerContainer, groupRows, targetGroupLevel, columnGroup) {
|
|
2633
|
+
if (!columnGroup || typeof columnGroup.getUniqueId !== 'function') {
|
|
2634
|
+
return null;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
var groupId = columnGroup.getUniqueId();
|
|
2638
|
+
var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
|
|
2639
|
+
var targetGroupRow = groupRows[groupRowIndex];
|
|
2640
|
+
|
|
2641
|
+
if (!targetGroupRow) {
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
return targetGroupRow.querySelector("[col-id=\"" + escapeColumnIdSelector(groupId) + "\"]");
|
|
2646
|
+
};
|
|
2647
|
+
|
|
2648
|
+
var applyPivotRowGrandTotalGroupHeaderLabel = function applyPivotRowGrandTotalGroupHeaderLabel(gridRootElement, columnApi, measureCount, columnPivotFieldCount) {
|
|
2649
|
+
if (!gridRootElement || !columnApi || measureCount <= 1) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement);
|
|
2654
|
+
var displayedColumns = typeof columnApi.getAllDisplayedColumns === 'function' ? columnApi.getAllDisplayedColumns() : [];
|
|
2655
|
+
var rowGrandTotalColumns = displayedColumns.filter(function (column) {
|
|
2656
|
+
return String(column.getColId()).indexOf('PivotRowTotal_') === 0;
|
|
2657
|
+
});
|
|
2658
|
+
|
|
2659
|
+
if (rowGrandTotalColumns.length <= 1) {
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
var centerHeaderContainer = gridRootElement.querySelector('.ag-header-viewport .ag-header-container');
|
|
2664
|
+
|
|
2665
|
+
if (!centerHeaderContainer) {
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
var groupRows = Array.from(centerHeaderContainer.querySelectorAll('.ag-header-row-column-group'));
|
|
2670
|
+
|
|
2671
|
+
if (groupRows.length === 0) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
var targetGroupLevel = columnPivotFieldCount > 0 ? columnPivotFieldCount - 1 : 0;
|
|
2676
|
+
var rowGrandTotalGroupCells = findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns);
|
|
2677
|
+
|
|
2678
|
+
if (rowGrandTotalGroupCells.length === 0) {
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells);
|
|
2683
|
+
};
|
|
2684
|
+
|
|
2685
|
+
var clearPivotRowGrandTotalGroupHeaderMarkup = function clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement) {
|
|
2686
|
+
gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header, .dl-pivot-row-grand-total-group-header-sibling').forEach(function (element) {
|
|
2687
|
+
element.classList.remove('dl-pivot-row-grand-total-group-header', 'dl-pivot-row-grand-total-group-header-sibling');
|
|
2688
|
+
});
|
|
2689
|
+
gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header-label').forEach(function (label) {
|
|
2690
|
+
label.classList.remove('dl-pivot-row-grand-total-group-header-label');
|
|
2691
|
+
var labelElement = label;
|
|
2692
|
+
labelElement.textContent = '';
|
|
2693
|
+
labelElement.style.width = '';
|
|
2694
|
+
labelElement.style.display = '';
|
|
2695
|
+
labelElement.style.textAlign = '';
|
|
2696
|
+
});
|
|
2697
|
+
};
|
|
2698
|
+
|
|
2699
|
+
var findRowGrandTotalGroupHeaderCells = function findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns) {
|
|
2700
|
+
var cellsByColumnGroup = [];
|
|
2701
|
+
rowGrandTotalColumns.forEach(function (column) {
|
|
2702
|
+
var columnGroup = getColumnGroupAtHeaderLevel(column, targetGroupLevel);
|
|
2703
|
+
var matchingCell = findHeaderGroupCellByColumnGroup(centerHeaderContainer, groupRows, targetGroupLevel, columnGroup);
|
|
2704
|
+
|
|
2705
|
+
if (matchingCell) {
|
|
2706
|
+
cellsByColumnGroup.push(matchingCell);
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2709
|
+
|
|
2710
|
+
if (cellsByColumnGroup.length === rowGrandTotalColumns.length) {
|
|
2711
|
+
return cellsByColumnGroup;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
|
|
2715
|
+
var targetGroupRow = groupRows[groupRowIndex];
|
|
2716
|
+
|
|
2717
|
+
if (!targetGroupRow) {
|
|
2718
|
+
return cellsByColumnGroup;
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
var paddingCells = Array.from(targetGroupRow.querySelectorAll('.ag-header-group-cell-no-group'));
|
|
2722
|
+
var trailingPaddingCells = paddingCells.slice(-rowGrandTotalColumns.length);
|
|
2723
|
+
|
|
2724
|
+
if (trailingPaddingCells.length === rowGrandTotalColumns.length) {
|
|
2725
|
+
return trailingPaddingCells;
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
return cellsByColumnGroup;
|
|
2729
|
+
};
|
|
2730
|
+
|
|
2731
|
+
var applyGrandTotalLabelToGroupHeaderCells = function applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells) {
|
|
2732
|
+
var firstCell = rowGrandTotalGroupCells[0];
|
|
2733
|
+
var firstLabel = firstCell.querySelector('.ag-header-group-text, .ag-header-cell-text');
|
|
2734
|
+
|
|
2735
|
+
if (!firstLabel) {
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
var combinedWidth = rowGrandTotalGroupCells.reduce(function (totalWidth, cell) {
|
|
2740
|
+
return totalWidth + cell.offsetWidth;
|
|
2741
|
+
}, 0);
|
|
2742
|
+
firstLabel.textContent = 'Grand Total';
|
|
2743
|
+
firstLabel.style.width = combinedWidth + "px";
|
|
2744
|
+
firstLabel.style.display = 'inline-block';
|
|
2745
|
+
firstLabel.style.textAlign = 'center';
|
|
2746
|
+
firstLabel.classList.add('dl-pivot-row-grand-total-group-header-label');
|
|
2747
|
+
firstCell.classList.add('dl-pivot-row-grand-total-group-header');
|
|
2748
|
+
|
|
2749
|
+
for (var index = 1; index < rowGrandTotalGroupCells.length; index++) {
|
|
2750
|
+
rowGrandTotalGroupCells[index].classList.add('dl-pivot-row-grand-total-group-header-sibling');
|
|
2751
|
+
var siblingLabel = rowGrandTotalGroupCells[index].querySelector('.ag-header-group-text, .ag-header-cell-text');
|
|
2752
|
+
|
|
2753
|
+
if (siblingLabel) {
|
|
2754
|
+
siblingLabel.textContent = '';
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
|
|
2759
|
+
var applyPivotRowGrandTotalHeader = function applyPivotRowGrandTotalHeader(colDef, measureCount, measures) {
|
|
2760
|
+
if (!isPivotRowGrandTotalColumnDef(colDef)) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
if (measureCount <= 1) {
|
|
2765
|
+
colDef.headerName = 'Grand Total';
|
|
2766
|
+
return;
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
var measure = resolveMeasureFromPivotValueColumn(colDef, measures);
|
|
2770
|
+
|
|
2771
|
+
if (measure) {
|
|
2772
|
+
colDef.headerName = getMeasureCaption(measure);
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
delete colDef.headerValueGetter;
|
|
2776
|
+
};
|
|
2777
|
+
var collectPivotRowPath = function collectPivotRowPath(startNode) {
|
|
2778
|
+
var path = [];
|
|
2779
|
+
|
|
2780
|
+
if (!startNode) {
|
|
2781
|
+
return path;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
if (startNode.footer) {
|
|
2785
|
+
if (startNode.level === -1) {
|
|
2786
|
+
return path;
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
if (startNode.field != null && startNode.key !== undefined) {
|
|
2790
|
+
path.unshift({
|
|
2791
|
+
field: startNode.field,
|
|
2792
|
+
key: startNode.key
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
var node = startNode.parent;
|
|
2798
|
+
|
|
2799
|
+
while (node && node.level >= 0) {
|
|
2800
|
+
if (!node.footer && node.field != null && node.key !== undefined) {
|
|
2801
|
+
path.unshift({
|
|
2802
|
+
field: node.field,
|
|
2803
|
+
key: node.key
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
node = node.parent;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
return path;
|
|
2811
|
+
};
|
|
2812
|
+
var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(colDef, startNode, apiFields) {
|
|
2813
|
+
var columnFields = apiFields.filter(function (field) {
|
|
2814
|
+
return !isRowPivotField(field);
|
|
2815
|
+
});
|
|
2816
|
+
var rowFields = apiFields.filter(isRowPivotField);
|
|
2817
|
+
var pivotFields = [];
|
|
2818
|
+
var columnKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
|
|
2819
|
+
columnKeys.forEach(function (key, index) {
|
|
2820
|
+
if (key === undefined) {
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
var field = columnFields[index];
|
|
2825
|
+
|
|
2826
|
+
if (!field) {
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
pivotFields.push({
|
|
2831
|
+
FieldId: field.FieldId,
|
|
2832
|
+
FieldType: field.FieldType ? field.FieldType : 'Field',
|
|
2833
|
+
FieldValue: key,
|
|
2834
|
+
DateCode: field.DateCode
|
|
2835
|
+
});
|
|
2836
|
+
});
|
|
2837
|
+
collectPivotRowPath(startNode).forEach(function (pathItem) {
|
|
2838
|
+
var field = rowFields.find(function (f) {
|
|
2839
|
+
return f.PivotCode === pathItem.field;
|
|
2840
|
+
}) || apiFields.find(function (f) {
|
|
2841
|
+
return f.PivotCode === pathItem.field;
|
|
2842
|
+
});
|
|
2843
|
+
|
|
2844
|
+
if (!field) {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
pivotFields.push({
|
|
2849
|
+
FieldId: field.FieldId,
|
|
2850
|
+
FieldType: field.FieldType ? field.FieldType : 'Field',
|
|
2851
|
+
FieldValue: pathItem.key,
|
|
2852
|
+
DateCode: field.DateCode
|
|
2853
|
+
});
|
|
2854
|
+
});
|
|
2855
|
+
return pivotFields;
|
|
2856
|
+
};
|
|
2857
|
+
var getMeasureCaption = function getMeasureCaption(measure) {
|
|
2858
|
+
var displayName = typeof measure.DisplayName == 'string' ? measure.DisplayName : '';
|
|
2859
|
+
|
|
2860
|
+
if (measure.MeasureCode == 'Sum') {
|
|
2861
|
+
return ConvertStringToPascalCaseHelper(displayName.replace('Sum of ', ''));
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
return ConvertStringToPascalCaseHelper(displayName);
|
|
2865
|
+
};
|
|
2866
|
+
var parseJsonArray = function parseJsonArray(json) {
|
|
2867
|
+
if (isNullOrUndefinedOrEmpty(json)) return [];
|
|
2868
|
+
|
|
2869
|
+
try {
|
|
2870
|
+
var parsed = JSON.parse(json);
|
|
2871
|
+
return parsed || [];
|
|
2872
|
+
} catch (error) {
|
|
2873
|
+
return [];
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
var parsePivotTotalsSettings = function parsePivotTotalsSettings(json) {
|
|
2877
|
+
if (isNullOrUndefinedOrEmpty(json)) return {};
|
|
2878
|
+
|
|
2879
|
+
try {
|
|
2880
|
+
return JSON.parse(json) || {};
|
|
2881
|
+
} catch (error) {
|
|
2882
|
+
return {};
|
|
2883
|
+
}
|
|
2884
|
+
};
|
|
2885
|
+
|
|
2886
|
+
var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
|
|
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) {
|
|
2894
|
+
var _useState = React.useState(),
|
|
2895
|
+
widget = _useState[0],
|
|
2896
|
+
setWidget = _useState[1];
|
|
2897
|
+
|
|
2898
|
+
var _useState2 = React.useState(true),
|
|
2899
|
+
isLoading = _useState2[0],
|
|
2900
|
+
setIsLoading = _useState2[1];
|
|
2901
|
+
|
|
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
|
+
var widgetRefData = React.useRef(null);
|
|
2915
|
+
var tabledata = React.useRef();
|
|
2916
|
+
var gridApiRef = React.useRef(null);
|
|
2917
|
+
var columnApiRef = React.useRef(null);
|
|
2918
|
+
var gridContainerRef = React.useRef(null);
|
|
2919
|
+
var pivotFieldsRef = React.useRef([]);
|
|
2920
|
+
var pivotMeasuresRef = React.useRef([]);
|
|
2921
|
+
React.useEffect(function () {
|
|
2922
|
+
var _props$customChartPro;
|
|
2923
|
+
|
|
2924
|
+
applyAgGridLicense();
|
|
2925
|
+
|
|
2926
|
+
if (props.customChartProps && props.customChartProps.widget) {
|
|
2927
|
+
setWidget(props.customChartProps.widget);
|
|
2928
|
+
widgetRefData.current = props.customChartProps.widget;
|
|
2929
|
+
getPivotTableData(props.customChartProps.widget);
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
2933
|
+
var _widgetRefData$curren;
|
|
2934
|
+
|
|
2935
|
+
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
|
+
setWidget(_extends({}, updatedWidget));
|
|
2937
|
+
});
|
|
2938
|
+
document.addEventListener('resizeStop', handleResize);
|
|
2939
|
+
return function () {
|
|
2940
|
+
document.removeEventListener('resizeStop', handleResize);
|
|
2941
|
+
};
|
|
2942
|
+
}, []);
|
|
2943
|
+
React.useEffect(function () {
|
|
2944
|
+
if (!props.customChartProps.isInEditMode) return;
|
|
2945
|
+
|
|
2946
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
2947
|
+
gridContainerRef.current.classList.add('force-overflow-hidden');
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
setTimeout(function () {
|
|
2951
|
+
handleResize();
|
|
2952
|
+
|
|
2953
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
2954
|
+
gridContainerRef.current.classList.remove('force-overflow-hidden');
|
|
2955
|
+
}
|
|
2956
|
+
}, 5);
|
|
2957
|
+
}, [props.customChartProps.isInEditMode]);
|
|
2958
|
+
|
|
2959
|
+
var handleResize = function handleResize() {
|
|
2960
|
+
if (gridApiRef.current && gridApiRef.current.resetRowHeights) {
|
|
2961
|
+
gridApiRef.current.resetRowHeights();
|
|
2962
|
+
}
|
|
2963
|
+
};
|
|
2964
|
+
|
|
2965
|
+
var getPivotTableData = function getPivotTableData(widgetPm) {
|
|
2966
|
+
if (Session.Tenant == 0) {
|
|
2967
|
+
tabledata.current = [];
|
|
2968
|
+
setRowData([]);
|
|
2969
|
+
setIsLoading(false);
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
2974
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, 'PostGetPivotData');
|
|
2975
|
+
dashboardAnalyticsService.getPivotData(widgetPm).then(function (res) {
|
|
2976
|
+
tabledata.current = res.data;
|
|
2977
|
+
buildGridFromPivotResponse();
|
|
2978
|
+
setIsLoading(false);
|
|
2979
|
+
widgetLoadLogger.log(res);
|
|
2980
|
+
})["catch"](function (err) {
|
|
2981
|
+
console.log('Error while Getting Pivot Table Data: ', err);
|
|
2982
|
+
tabledata.current = null;
|
|
2983
|
+
setRowData([]);
|
|
2984
|
+
setIsLoading(false);
|
|
2985
|
+
});
|
|
2986
|
+
};
|
|
2987
|
+
|
|
2988
|
+
var lookupDisplayName = function lookupDisplayName(field, rawValue) {
|
|
2989
|
+
var pivotData = tabledata.current && tabledata.current.PivotData ? tabledata.current.PivotData : [];
|
|
2990
|
+
return getPivotDisplayName(pivotData, field.PivotName, field.PivotCode, rawValue);
|
|
2991
|
+
};
|
|
2992
|
+
|
|
2993
|
+
var lookupDisplayNameByFieldCode = function lookupDisplayNameByFieldCode(fieldCode, rawValue) {
|
|
2994
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
2995
|
+
return f.PivotCode === fieldCode;
|
|
2996
|
+
});
|
|
2997
|
+
if (!field) return rawValue == null ? '' : String(rawValue);
|
|
2998
|
+
return lookupDisplayName(field, rawValue);
|
|
2999
|
+
};
|
|
3000
|
+
|
|
3001
|
+
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef) {
|
|
3002
|
+
colDef.sortable = false;
|
|
3003
|
+
colDef.filter = false;
|
|
3004
|
+
colDef.cellClass = 'dl-ag-pivot-data-cell';
|
|
3005
|
+
colDef.type = 'numericColumn';
|
|
3006
|
+
};
|
|
3007
|
+
|
|
3008
|
+
var buildGridFromPivotResponse = function buildGridFromPivotResponse() {
|
|
3009
|
+
if (!tabledata.current || !tabledata.current.PivoFields || !tabledata.current.PivotMeasures) {
|
|
3010
|
+
setRowData([]);
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
var apiFields = tabledata.current.PivoFields;
|
|
3015
|
+
var apiMeasures = tabledata.current.PivotMeasures;
|
|
3016
|
+
pivotFieldsRef.current = apiFields;
|
|
3017
|
+
pivotMeasuresRef.current = apiMeasures;
|
|
3018
|
+
setMeasureCount(apiMeasures.length);
|
|
3019
|
+
var rowFields = apiFields.filter(isRowPivotField);
|
|
3020
|
+
var columnFields = apiFields.filter(function (field) {
|
|
3021
|
+
return !isRowPivotField(field);
|
|
3022
|
+
});
|
|
3023
|
+
var defs = [];
|
|
3024
|
+
rowFields.forEach(function (field, index) {
|
|
3025
|
+
defs.push(createRowGroupColDef(field, index));
|
|
3026
|
+
});
|
|
3027
|
+
columnFields.forEach(function (field, index) {
|
|
3028
|
+
defs.push(createPivotColDef(field, index));
|
|
3029
|
+
});
|
|
3030
|
+
apiMeasures.forEach(function (measure) {
|
|
3031
|
+
defs.push(createMeasureColDef(measure));
|
|
3032
|
+
});
|
|
3033
|
+
setColumnDefs(defs);
|
|
3034
|
+
setRowData(tabledata.current.PivotData || []);
|
|
3035
|
+
};
|
|
3036
|
+
|
|
3037
|
+
var createRowGroupColDef = function createRowGroupColDef(field, index) {
|
|
3038
|
+
return {
|
|
3039
|
+
field: field.PivotCode,
|
|
3040
|
+
headerName: field.DisplayName,
|
|
3041
|
+
rowGroup: true,
|
|
3042
|
+
rowGroupIndex: index,
|
|
3043
|
+
enableRowGroup: true,
|
|
3044
|
+
hide: true,
|
|
3045
|
+
width: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3046
|
+
wrapText: true,
|
|
3047
|
+
autoHeight: true,
|
|
3048
|
+
sortable: false,
|
|
3049
|
+
filter: false,
|
|
3050
|
+
comparator: function comparator(a, b) {
|
|
3051
|
+
return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
|
|
3052
|
+
},
|
|
3053
|
+
valueFormatter: function valueFormatter(params) {
|
|
3054
|
+
return lookupDisplayName(field, params.value);
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
};
|
|
3058
|
+
|
|
3059
|
+
var createPivotColDef = function createPivotColDef(field, index) {
|
|
3060
|
+
return {
|
|
3061
|
+
field: field.PivotCode,
|
|
3062
|
+
headerName: field.DisplayName,
|
|
3063
|
+
pivot: true,
|
|
3064
|
+
pivotIndex: index,
|
|
3065
|
+
enablePivot: true,
|
|
3066
|
+
hide: true,
|
|
3067
|
+
sortable: false,
|
|
3068
|
+
filter: false,
|
|
3069
|
+
pivotComparator: function pivotComparator(a, b) {
|
|
3070
|
+
return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
var createMeasureColDef = function createMeasureColDef(measure) {
|
|
3076
|
+
return {
|
|
3077
|
+
field: measure.PivotMeasureCode,
|
|
3078
|
+
headerName: getMeasureCaption(measure),
|
|
3079
|
+
aggFunc: 'logitudeSum',
|
|
3080
|
+
enableValue: true,
|
|
3081
|
+
wrapText: true,
|
|
3082
|
+
autoHeight: true,
|
|
3083
|
+
sortable: false,
|
|
3084
|
+
filter: false,
|
|
3085
|
+
cellClass: 'dl-ag-pivot-data-cell',
|
|
3086
|
+
type: 'numericColumn',
|
|
3087
|
+
valueFormatter: function valueFormatter(params) {
|
|
3088
|
+
return formatPivotMeasureValue(params.value, measure);
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
3091
|
+
};
|
|
3092
|
+
|
|
3093
|
+
var isRowsEmptyAndColumnsNotEmpty = function isRowsEmptyAndColumnsNotEmpty() {
|
|
3094
|
+
var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
|
|
3095
|
+
var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
|
|
3096
|
+
return pivotRows.length === 0 && pivotColumns.length > 0;
|
|
3097
|
+
};
|
|
3098
|
+
|
|
3099
|
+
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
3100
|
+
var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
|
|
3101
|
+
var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
|
|
3102
|
+
return pivotRows.length > 0 && pivotColumns.length === 0;
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3106
|
+
if (isRowsEmptyAndColumnsNotEmpty()) return true;
|
|
3107
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3108
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowRowsGrandTotal) ? !!settings.ShowRowsGrandTotal : false;
|
|
3109
|
+
};
|
|
3110
|
+
|
|
3111
|
+
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
3112
|
+
if (isRowsNotEmptyAndColumnsEmpty()) return true;
|
|
3113
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3114
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowColumnsGrandTotal) ? !!settings.ShowColumnsGrandTotal : false;
|
|
3115
|
+
};
|
|
3116
|
+
|
|
3117
|
+
var canShowRowsTotal = function canShowRowsTotal() {
|
|
3118
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3119
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowRowsTotal) ? !!settings.ShowRowsTotal : false;
|
|
3120
|
+
};
|
|
3121
|
+
|
|
3122
|
+
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
3123
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3124
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowColumnsTotal) ? !!settings.ShowColumnsTotal : false;
|
|
3125
|
+
};
|
|
3126
|
+
|
|
3127
|
+
var isSingleMeasurePivot = measureCount <= 1;
|
|
3128
|
+
var processSecondaryColGroupDef = React.useCallback(function (colGroupDef) {
|
|
3129
|
+
var columnFields = pivotFieldsRef.current.filter(function (field) {
|
|
3130
|
+
return !isRowPivotField(field);
|
|
3131
|
+
});
|
|
3132
|
+
var headerName = resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName);
|
|
3133
|
+
|
|
3134
|
+
if (headerName) {
|
|
3135
|
+
colGroupDef.headerName = headerName;
|
|
3136
|
+
}
|
|
3137
|
+
}, []);
|
|
3138
|
+
var processSecondaryColDef = React.useCallback(function (colDef) {
|
|
3139
|
+
var columnFields = pivotFieldsRef.current.filter(function (field) {
|
|
3140
|
+
return !isRowPivotField(field);
|
|
3141
|
+
});
|
|
3142
|
+
var colDefAny = colDef;
|
|
3143
|
+
|
|
3144
|
+
if (colDefAny.colId && String(colDefAny.colId).indexOf('PivotRowTotal_') === 0) {
|
|
3145
|
+
applyPivotRowGrandTotalHeader(colDefAny, pivotMeasuresRef.current.length, pivotMeasuresRef.current);
|
|
3146
|
+
} else {
|
|
3147
|
+
var headerName = resolvePivotLeafHeaderName(colDefAny, columnFields, lookupDisplayName, pivotMeasuresRef.current.length);
|
|
3148
|
+
|
|
3149
|
+
if (headerName) {
|
|
3150
|
+
colDef.headerName = headerName;
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
applyPivotDataCellFormatting(colDef);
|
|
3155
|
+
|
|
3156
|
+
colDef.valueFormatter = function (params) {
|
|
3157
|
+
var measure = resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
|
|
3158
|
+
if (!measure) return '';
|
|
3159
|
+
return formatPivotMeasureValue(params.value, measure);
|
|
3160
|
+
};
|
|
3161
|
+
}, []);
|
|
3162
|
+
var onCellClicked = React.useCallback(function (event) {
|
|
3163
|
+
var colDef = event.colDef;
|
|
3164
|
+
if (!colDef || !colDef.pivotValueColumn) return;
|
|
3165
|
+
if (isPivotMeasureValueEmpty(event.value)) return;
|
|
3166
|
+
var pivotFields = buildPivotDrillDownPivotFields(colDef, event.node, pivotFieldsRef.current);
|
|
3167
|
+
props.customChartProps.onSelectDataPoint({
|
|
3168
|
+
MeasureFieldId: '',
|
|
3169
|
+
MeasureFieldType: '',
|
|
3170
|
+
Widget: props.customChartProps.widget,
|
|
3171
|
+
MeasureCode: '',
|
|
3172
|
+
Formula: '',
|
|
3173
|
+
GroupById: '',
|
|
3174
|
+
PivotFields: pivotFields
|
|
3175
|
+
});
|
|
3176
|
+
}, []);
|
|
3177
|
+
var defaultColDef = React.useMemo(function () {
|
|
3178
|
+
return {
|
|
3179
|
+
sortable: false,
|
|
3180
|
+
filter: false,
|
|
3181
|
+
resizable: false,
|
|
3182
|
+
suppressMenu: true,
|
|
3183
|
+
wrapText: true,
|
|
3184
|
+
autoHeight: true
|
|
3185
|
+
};
|
|
3186
|
+
}, []);
|
|
3187
|
+
var autoGroupColumnDef = React.useMemo(function () {
|
|
3188
|
+
return {
|
|
3189
|
+
minWidth: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3190
|
+
width: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3191
|
+
sortable: false,
|
|
3192
|
+
filter: false,
|
|
3193
|
+
wrapText: true,
|
|
3194
|
+
autoHeight: true,
|
|
3195
|
+
cellClass: 'dl-ag-pivot-row-label-cell',
|
|
3196
|
+
headerValueGetter: function headerValueGetter(params) {
|
|
3197
|
+
var colDef = params.colDef;
|
|
3198
|
+
var showRowGroup = colDef && colDef.showRowGroup;
|
|
3199
|
+
if (!showRowGroup) return '';
|
|
3200
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
3201
|
+
return f.PivotCode === showRowGroup;
|
|
3202
|
+
});
|
|
3203
|
+
return field ? field.DisplayName : '';
|
|
3204
|
+
},
|
|
3205
|
+
valueFormatter: function valueFormatter(params) {
|
|
3206
|
+
var colDef = params.colDef;
|
|
3207
|
+
var showRowGroup = colDef && colDef.showRowGroup;
|
|
3208
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
3209
|
+
return f.PivotCode === showRowGroup;
|
|
3210
|
+
});
|
|
3211
|
+
if (!field) return params.value == null ? '' : String(params.value);
|
|
3212
|
+
return lookupDisplayName(field, params.value);
|
|
3213
|
+
},
|
|
3214
|
+
cellRendererParams: {
|
|
3215
|
+
suppressCount: true,
|
|
3216
|
+
footerValueGetter: function footerValueGetter(params) {
|
|
3217
|
+
var fieldCode = params.node && params.node.field ? params.node.field : params.colDef && params.colDef.showRowGroup ? params.colDef.showRowGroup : null;
|
|
3218
|
+
return getPivotGroupFooterLabel(params.node, fieldCode, params.value, lookupDisplayNameByFieldCode);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
}, []);
|
|
3223
|
+
var aggFuncs = React.useMemo(function () {
|
|
3224
|
+
return {
|
|
3225
|
+
logitudeSum: logitudeSumAgg
|
|
3226
|
+
};
|
|
3227
|
+
}, []);
|
|
3228
|
+
var scheduleRowGrandTotalHeaderLabel = React.useCallback(function () {
|
|
3229
|
+
var columnPivotFieldCount = pivotFieldsRef.current.filter(function (field) {
|
|
3230
|
+
return !isRowPivotField(field);
|
|
3231
|
+
}).length;
|
|
3232
|
+
|
|
3233
|
+
var applyLabel = function applyLabel() {
|
|
3234
|
+
applyPivotRowGrandTotalGroupHeaderLabel(gridContainerRef.current, columnApiRef.current, measureCount, columnPivotFieldCount);
|
|
3235
|
+
};
|
|
3236
|
+
|
|
3237
|
+
window.requestAnimationFrame(function () {
|
|
3238
|
+
window.requestAnimationFrame(function () {
|
|
3239
|
+
applyLabel();
|
|
3240
|
+
window.setTimeout(applyLabel, 150);
|
|
3241
|
+
});
|
|
3242
|
+
});
|
|
3243
|
+
}, [measureCount]);
|
|
3244
|
+
|
|
3245
|
+
var onGridReady = function onGridReady(event) {
|
|
3246
|
+
gridApiRef.current = event.api;
|
|
3247
|
+
columnApiRef.current = event.columnApi;
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
var onFirstDataRendered = function onFirstDataRendered(event) {
|
|
3251
|
+
columnApiRef.current = event.columnApi;
|
|
3252
|
+
var columnApi = event.columnApi;
|
|
3253
|
+
if (!columnApi || !columnApi.getAllDisplayedColumns) return;
|
|
3254
|
+
var autoGroupColumnIds = columnApi.getAllDisplayedColumns().map(function (col) {
|
|
3255
|
+
return col.getColId();
|
|
3256
|
+
}).filter(function (colId) {
|
|
3257
|
+
return colId.indexOf('ag-Grid-AutoColumn') === 0;
|
|
3258
|
+
});
|
|
3259
|
+
|
|
3260
|
+
if (autoGroupColumnIds.length > 0 && columnApi.autoSizeColumns) {
|
|
3261
|
+
columnApi.autoSizeColumns(autoGroupColumnIds, false);
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
var onColumnPivotChanged = function onColumnPivotChanged() {
|
|
3268
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3269
|
+
};
|
|
3270
|
+
|
|
3271
|
+
var onColumnResized = function onColumnResized() {
|
|
3272
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3273
|
+
};
|
|
3274
|
+
|
|
3275
|
+
var gridWrapperClassName = 'ag-theme-balham pivot-grid-element dl-ag-pivot-grid';
|
|
3276
|
+
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
3277
|
+
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
3278
|
+
}, React__default.createElement(progressspinner.ProgressSpinner, {
|
|
3279
|
+
style: {
|
|
3280
|
+
width: '40px',
|
|
3281
|
+
height: '40px'
|
|
3282
|
+
},
|
|
3283
|
+
strokeWidth: "4",
|
|
3284
|
+
animationDuration: "2s"
|
|
3285
|
+
})) : React__default.createElement("div", {
|
|
3286
|
+
ref: gridContainerRef,
|
|
3287
|
+
className: gridWrapperClassName
|
|
3288
|
+
}, React__default.createElement(agGridReact.AgGridReact, {
|
|
3289
|
+
rowData: rowData,
|
|
3290
|
+
columnDefs: columnDefs,
|
|
3291
|
+
defaultColDef: defaultColDef,
|
|
3292
|
+
autoGroupColumnDef: autoGroupColumnDef,
|
|
3293
|
+
aggFuncs: aggFuncs,
|
|
3294
|
+
pivotMode: true,
|
|
3295
|
+
groupDisplayType: "multipleColumns",
|
|
3296
|
+
groupDefaultExpanded: -1,
|
|
3297
|
+
suppressAggFuncInHeader: true,
|
|
3298
|
+
removePivotHeaderRowWhenSingleValueColumn: isSingleMeasurePivot,
|
|
3299
|
+
groupIncludeFooter: canShowRowsTotal(),
|
|
3300
|
+
groupIncludeTotalFooter: canShowRowsGrandTotal(),
|
|
3301
|
+
pivotRowTotals: canShowColumnsGrandTotal() ? 'after' : undefined,
|
|
3302
|
+
pivotColumnGroupTotals: canShowColumnsTotal() ? 'after' : undefined,
|
|
3303
|
+
processSecondaryColGroupDef: processSecondaryColGroupDef,
|
|
3304
|
+
processSecondaryColDef: processSecondaryColDef,
|
|
3305
|
+
onCellClicked: onCellClicked,
|
|
3306
|
+
onGridReady: onGridReady,
|
|
3307
|
+
onFirstDataRendered: onFirstDataRendered,
|
|
3308
|
+
onColumnPivotChanged: onColumnPivotChanged,
|
|
3309
|
+
onColumnResized: onColumnResized,
|
|
3310
|
+
animateRows: false,
|
|
3311
|
+
suppressContextMenu: true,
|
|
3312
|
+
suppressMovableColumns: true,
|
|
3313
|
+
headerHeight: 36,
|
|
3314
|
+
rowHeight: 36
|
|
3315
|
+
})));
|
|
3316
|
+
});
|
|
3317
|
+
|
|
2376
3318
|
var parseSelectedQueries = function parseSelectedQueries(widgetJson) {
|
|
2377
3319
|
if (!widgetJson) {
|
|
2378
3320
|
return [];
|
|
@@ -2453,7 +3395,9 @@ var CustomChart = function CustomChart(props) {
|
|
|
2453
3395
|
});
|
|
2454
3396
|
|
|
2455
3397
|
case "pivot":
|
|
2456
|
-
return React__default.createElement(
|
|
3398
|
+
return props.useAgGridPivot ? React__default.createElement(AgPivotGrid, {
|
|
3399
|
+
customChartProps: props
|
|
3400
|
+
}) : React__default.createElement(PivotTable, {
|
|
2457
3401
|
customChartProps: props
|
|
2458
3402
|
});
|
|
2459
3403
|
|
|
@@ -4296,6 +5240,7 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
|
|
|
4296
5240
|
if (((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "kpi") return React__default.createElement(CustomChart, {
|
|
4297
5241
|
isInEditMode: props.isInEditMode,
|
|
4298
5242
|
isPreviewModeActive: props.isPreviewModeActive,
|
|
5243
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4299
5244
|
dataBinding: props.dataBinding,
|
|
4300
5245
|
widget: widget.current,
|
|
4301
5246
|
widgetRef: props.widgetRef,
|
|
@@ -4307,6 +5252,7 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
|
|
|
4307
5252
|
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, {
|
|
4308
5253
|
isInEditMode: props.isInEditMode,
|
|
4309
5254
|
isPreviewModeActive: props.isPreviewModeActive,
|
|
5255
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4310
5256
|
dataBinding: props.dataBinding,
|
|
4311
5257
|
widget: widget.current,
|
|
4312
5258
|
widgetRef: props.widgetRef,
|
|
@@ -4751,6 +5697,7 @@ var DashboardDesigner = function DashboardDesigner(props) {
|
|
|
4751
5697
|
editBtnClicked: editWidget,
|
|
4752
5698
|
deleteBtnClicked: confirmDeleteWidget,
|
|
4753
5699
|
onSelectDataPoint: props.onSelectDataPoint,
|
|
5700
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4754
5701
|
duplicateBtnClicked: copyWidget,
|
|
4755
5702
|
copyToClipboardBtnClicked: copyWidgetToClipboard,
|
|
4756
5703
|
ref: function ref(el) {
|
|
@@ -4781,6 +5728,8 @@ var layoutGridProps = {
|
|
|
4781
5728
|
var Dashboard = function Dashboard(props) {
|
|
4782
5729
|
var _previewWidget$Layout, _previewWidget$Layout2;
|
|
4783
5730
|
|
|
5731
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5732
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
4784
5733
|
var Widgetlayouts = React.useRef({
|
|
4785
5734
|
lg: []
|
|
4786
5735
|
});
|
|
@@ -4809,6 +5758,8 @@ var Dashboard = function Dashboard(props) {
|
|
|
4809
5758
|
Session.Token = props === null || props === void 0 ? void 0 : props.token;
|
|
4810
5759
|
Session.NumberFormatCode = props === null || props === void 0 ? void 0 : props.numberFormatCode;
|
|
4811
5760
|
Session.isMasterNumberClickable = props === null || props === void 0 ? void 0 : props.isMasterNumberClickable;
|
|
5761
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5762
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
4812
5763
|
setIsPreviewModeActive(props.isPreviewMode);
|
|
4813
5764
|
props.dataBinding.onGetLayouts.subscribe(function (layouts) {
|
|
4814
5765
|
Widgetlayouts.current = layouts;
|
|
@@ -4822,6 +5773,10 @@ var Dashboard = function Dashboard(props) {
|
|
|
4822
5773
|
setWidgetlayoutsState(deepClone(Widgetlayouts.current));
|
|
4823
5774
|
});
|
|
4824
5775
|
}, []);
|
|
5776
|
+
React.useEffect(function () {
|
|
5777
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5778
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
5779
|
+
}, [props.useAgGridPivot, props.agGridLicenseKey]);
|
|
4825
5780
|
React.useEffect(function () {
|
|
4826
5781
|
if (props.widgetData) {
|
|
4827
5782
|
setPreviewWidget(JSON.parse(JSON.stringify(props.widgetData)));
|
|
@@ -4892,13 +5847,15 @@ var Dashboard = function Dashboard(props) {
|
|
|
4892
5847
|
},
|
|
4893
5848
|
onSelectDataPoint: function onSelectDataPoint() {
|
|
4894
5849
|
return true;
|
|
4895
|
-
}
|
|
5850
|
+
},
|
|
5851
|
+
useAgGridPivot: props.useAgGridPivot
|
|
4896
5852
|
}))) : React.createElement("div", {
|
|
4897
5853
|
className: 'dl-full-hight'
|
|
4898
5854
|
}, React.createElement("div", {
|
|
4899
5855
|
className: 'dl-dashboard-body'
|
|
4900
5856
|
}, React.createElement(DashboardDesigner, {
|
|
4901
5857
|
onSelectDataPoint: props.onSelectDataPoint,
|
|
5858
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4902
5859
|
Widgetlayouts: widgetlayoutsState,
|
|
4903
5860
|
dataBinding: props.dataBinding,
|
|
4904
5861
|
editMode: isInEditMode,
|