logitude-dashboard-library 3.1.43 → 3.1.44

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.
@@ -811,6 +811,36 @@ $dark-grey: #717585;
811
811
  align-items: flex-start;
812
812
  }
813
813
 
814
+ .dl-pivot-chart-container {
815
+ overflow: auto;
816
+ position: absolute;
817
+ top: -1px;
818
+ right: 0;
819
+ left: 0;
820
+ bottom: 0;
821
+ height: calc(100% - 10px);
822
+ width: 100%;
823
+ margin: 0 auto;
824
+
825
+ &::-webkit-scrollbar {
826
+ width: 10px;
827
+ height: 10px
828
+ }
829
+
830
+ &::-webkit-scrollbar-thumb {
831
+ border: 1px solid rgba(0, 0, 0, 0);
832
+ background-clip: padding-box;
833
+ border-radius: 9999px;
834
+ background-color: #D9D9D9;
835
+ }
836
+
837
+ &::-webkit-scrollbar-track {
838
+ background: #F3F3F3;
839
+ border: 1px solid white;
840
+ border-radius: 9999px;
841
+ }
842
+ }
843
+
814
844
  .dl-table-chart-container {
815
845
  overflow: auto;
816
846
  position: absolute;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { CustomChartProps } from './CustomChart';
3
+ declare type PivotChartProps = {
4
+ customChartProps: CustomChartProps;
5
+ };
6
+ declare const PivotTable: (props: PivotChartProps) => React.JSX.Element;
7
+ export default PivotTable;
package/dist/index.js CHANGED
@@ -9,6 +9,9 @@ var moment = _interopDefault(require('moment'));
9
9
  var uuid = require('uuid');
10
10
  var datatable = require('primereact/datatable');
11
11
  var column = require('primereact/column');
12
+ var PivotGrid = require('devextreme-react/pivot-grid');
13
+ var PivotGrid__default = _interopDefault(PivotGrid);
14
+ var CustomStore = _interopDefault(require('devextreme/data/custom_store'));
12
15
  var ReactFC = _interopDefault(require('react-fusioncharts'));
13
16
  var FusionCharts = _interopDefault(require('fusioncharts'));
14
17
  var Charts = _interopDefault(require('fusioncharts/fusioncharts.charts'));
@@ -232,6 +235,10 @@ var DashboardAnalyticsService = /*#__PURE__*/function () {
232
235
  return this._ApiServices.get("/api/analyticsfactsmetadatas/getsingle?id=" + entityId);
233
236
  };
234
237
 
238
+ _proto.getPivotData = function getPivotData(widget) {
239
+ return this._ApiServices.post("/api/DashboardAnalytics/PostGetPivotData", widget);
240
+ };
241
+
235
242
  return DashboardAnalyticsService;
236
243
  }();
237
244
 
@@ -1476,8 +1483,123 @@ var TableChart = function TableChart(props) {
1476
1483
  }));
1477
1484
  };
1478
1485
 
1486
+ var PivotTable = function PivotTable(props) {
1487
+ var pivotGridRef = React.useRef(null);
1488
+ var tabledata = React.useRef();
1489
+ var customizeCells = React.useCallback(function (e) {
1490
+ if (e.cell.rowPath && e.cell.rowPath[0] === "Germany" && e.cell.columnPath && e.cell.columnPath[0] === "Export" && e.cell.columnPath[1] === "Air") {
1491
+ e.cellElement.children[0].style.padding = "6px";
1492
+ e.cellElement.children[0].style.borderRadius = "6px";
1493
+ e.cellElement.children[0].style.backgroundColor = "#f4433673";
1494
+ }
1495
+
1496
+ if (e.cell.rowPath && e.cell.rowPath[0] === "USA" && e.cell.columnPath && e.cell.columnPath[0] === "Import" && e.cell.columnPath[1] === "Inland") {
1497
+ e.cellElement.children[0].style.padding = "6px";
1498
+ e.cellElement.children[0].style.borderRadius = "6px";
1499
+ e.cellElement.children[0].style.backgroundColor = "#03a9f4ad";
1500
+ }
1501
+ }, []);
1502
+ var onCellClick = React.useCallback(function (e) {
1503
+ if (e.area === 'data') {
1504
+ console.log("Pivot Cell Data", e);
1505
+ }
1506
+ }, []);
1507
+
1508
+ var getColumnNameByColumnId = function getColumnNameByColumnId(fieldName, dataField, datafieldValue) {
1509
+ var data = tabledata.current.PivotData.find(function (el) {
1510
+ return el[dataField] == datafieldValue;
1511
+ });
1512
+ return data ? data[fieldName] : '---';
1513
+ };
1514
+
1515
+ var setPivotDataSourceFields = function setPivotDataSourceFields() {
1516
+ if (tabledata.current && tabledata.current.PivoFields && tabledata.current.PivotMeasures) {
1517
+ var _pivotGridRef$current;
1518
+
1519
+ var pivotRowsAndColumnsFields = tabledata.current.PivoFields.map(function (field) {
1520
+ return {
1521
+ dataField: field.PivotCode,
1522
+ caption: field.DisplayName,
1523
+ name: field.PivotName,
1524
+ width: 150,
1525
+ allowSorting: false,
1526
+ allowFiltering: false,
1527
+ area: field.PivotCode && field.PivotCode.includes('Row') ? 'row' : 'column',
1528
+ expanded: true,
1529
+ customizeText: function customizeText(cellInfo) {
1530
+ return getColumnNameByColumnId(field.PivotName, field.PivotCode, cellInfo.value);
1531
+ }
1532
+ };
1533
+ });
1534
+ var pivotDataCellsFields = tabledata.current.PivotMeasures.map(function (measure) {
1535
+ return {
1536
+ dataField: measure.PivotMeasureCode,
1537
+ dataType: 'string',
1538
+ area: 'data',
1539
+ caption: measure.DisplayName
1540
+ };
1541
+ });
1542
+ var fakeCellDataObject = {
1543
+ dataField: '',
1544
+ dataType: 'string',
1545
+ area: 'data',
1546
+ caption: "",
1547
+ visible: false
1548
+ };
1549
+ pivotDataCellsFields.push(fakeCellDataObject);
1550
+ var AllfieldsData = [].concat(pivotRowsAndColumnsFields, pivotDataCellsFields);
1551
+ (_pivotGridRef$current = pivotGridRef.current) === null || _pivotGridRef$current === void 0 ? void 0 : _pivotGridRef$current.instance.getDataSource().fields(AllfieldsData);
1552
+ }
1553
+ };
1554
+
1555
+ var dataStore = new CustomStore({
1556
+ load: function load() {
1557
+ var dashboardAnalyticsService = new DashboardAnalyticsService();
1558
+ return dashboardAnalyticsService.getPivotData(props.customChartProps.widget).then(function (res) {
1559
+ tabledata.current = res.data;
1560
+ setPivotDataSourceFields();
1561
+ return [].concat(res.data.PivotData);
1562
+ })["catch"](function (err) {
1563
+ return console.log("Error while Getting Pivot Table Data: ", err);
1564
+ });
1565
+ }
1566
+ });
1567
+ var dataSource = {
1568
+ store: dataStore,
1569
+ fields: []
1570
+ };
1571
+ return React__default.createElement(PivotGrid__default, {
1572
+ ref: pivotGridRef,
1573
+ id: "pivotGridId",
1574
+ dataSource: dataSource,
1575
+ allowExpandAll: true,
1576
+ showBorders: true,
1577
+ width: "100%",
1578
+ style: {
1579
+ margin: "0 auto"
1580
+ },
1581
+ onCellClick: onCellClick,
1582
+ showRowGrandTotals: false,
1583
+ showColumnGrandTotals: false,
1584
+ showRowTotals: false,
1585
+ showColumnTotals: false
1586
+ }, React__default.createElement(PivotGrid.FieldPanel, {
1587
+ showColumnFields: false,
1588
+ showDataFields: false,
1589
+ showFilterFields: false,
1590
+ showRowFields: true,
1591
+ allowFieldDragging: false,
1592
+ visible: true
1593
+ }), React__default.createElement(PivotGrid.FieldChooser, {
1594
+ enabled: false
1595
+ }), React__default.createElement(PivotGrid.Scrolling, {
1596
+ mode: "virtual",
1597
+ useNative: true
1598
+ }));
1599
+ };
1600
+
1479
1601
  var CustomChart = function CustomChart(props) {
1480
- var _props$widget2;
1602
+ var _props$widget2, _props$widget3;
1481
1603
 
1482
1604
  var project = function project() {
1483
1605
  var _props$widget;
@@ -1493,13 +1615,18 @@ var CustomChart = function CustomChart(props) {
1493
1615
  customChartProps: props
1494
1616
  });
1495
1617
 
1618
+ case "pivot":
1619
+ return React__default.createElement(PivotTable, {
1620
+ customChartProps: props
1621
+ });
1622
+
1496
1623
  default:
1497
1624
  return React__default.createElement("div", null, "Invalid Type");
1498
1625
  }
1499
1626
  };
1500
1627
 
1501
1628
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
1502
- className: props.widget && ((_props$widget2 = props.widget) === null || _props$widget2 === void 0 ? void 0 : _props$widget2.TypeCode) == 'table' ? "dl-custom-chart-container dl-table-chart-container" : "dl-custom-chart-container"
1629
+ className: "dl-custom-chart-container " + (props.widget && ((_props$widget2 = props.widget) === null || _props$widget2 === void 0 ? void 0 : _props$widget2.TypeCode) == 'table' ? 'dl-table-chart-container' : '') + " " + (props.widget && ((_props$widget3 = props.widget) === null || _props$widget3 === void 0 ? void 0 : _props$widget3.TypeCode) == 'pivot' ? 'dl-pivot-chart-container' : '')
1503
1630
  }, project()));
1504
1631
  };
1505
1632
 
@@ -2837,7 +2964,7 @@ var FusionChart$1 = React.forwardRef(function (props, comRef) {
2837
2964
  });
2838
2965
 
2839
2966
  var WidgetCard = React.forwardRef(function (props, comRef) {
2840
- var _widget$current12, _widget$current13, _widget$current14;
2967
+ var _widget$current13, _widget$current14, _widget$current15;
2841
2968
 
2842
2969
  var widget = React.useRef();
2843
2970
 
@@ -2906,18 +3033,18 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
2906
3033
  };
2907
3034
 
2908
3035
  var GetChartComponent = function GetChartComponent() {
2909
- var _widget$current4, _widget$current5, _widget$current6, _widget$current7;
3036
+ var _widget$current4, _widget$current5, _widget$current6, _widget$current7, _widget$current8;
2910
3037
 
2911
3038
  if (isLoading || !((_widget$current4 = widget.current) !== null && _widget$current4 !== void 0 && _widget$current4.TypeCode)) return "";
2912
- if (((_widget$current5 = widget.current) === null || _widget$current5 === void 0 ? void 0 : _widget$current5.TypeCode) == "kpi" || ((_widget$current6 = widget.current) === null || _widget$current6 === void 0 ? void 0 : _widget$current6.TypeCode) == "table") return React__default.createElement(CustomChart, {
2913
- isInEditMode: props.isInEditMode,
3039
+ if (((_widget$current5 = widget.current) === null || _widget$current5 === void 0 ? void 0 : _widget$current5.TypeCode) == "kpi" || ((_widget$current6 = widget.current) === null || _widget$current6 === void 0 ? void 0 : _widget$current6.TypeCode) == "table" || ((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "pivot") return React__default.createElement(CustomChart, {
3040
+ isInEditMode: false,
2914
3041
  isPreviewModeActive: props.isPreviewModeActive,
2915
3042
  dataBinding: props.dataBinding,
2916
3043
  widget: widget.current,
2917
3044
  widgetRef: props.widgetRef,
2918
3045
  onSelectDataPoint: props.onSelectDataPoint
2919
3046
  });
2920
- if (((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "gauge") return React__default.createElement(FusionChart$1, {
3047
+ if (((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.TypeCode) == "gauge") return React__default.createElement(FusionChart$1, {
2921
3048
  ref: fusionChartRef,
2922
3049
  dataBinding: props.dataBinding,
2923
3050
  widget: widget.current,
@@ -2937,8 +3064,12 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
2937
3064
  return widget && widget.current && widget.current.TypeCode == 'table';
2938
3065
  };
2939
3066
 
3067
+ var isTableOrPivotWidget = function isTableOrPivotWidget() {
3068
+ return widget && widget.current && (widget.current.TypeCode == 'table' || widget.current.TypeCode == 'pivot');
3069
+ };
3070
+
2940
3071
  var getwidgetTitlesContainer = function getwidgetTitlesContainer() {
2941
- return isTableWidget() ? "widget-table-titles-container" : "widget-titles-container";
3072
+ return isTableOrPivotWidget() ? "widget-table-titles-container" : "widget-titles-container";
2942
3073
  };
2943
3074
 
2944
3075
  var drilldownToTableData = function drilldownToTableData() {
@@ -2953,21 +3084,21 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
2953
3084
  };
2954
3085
 
2955
3086
  var isThereTitle = function isThereTitle() {
2956
- var _widget$current8, _widget$current9;
3087
+ var _widget$current9, _widget$current10;
2957
3088
 
2958
- return ((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.Title) && ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.Title.length) > 0;
3089
+ return ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.Title) && ((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.Title.length) > 0;
2959
3090
  };
2960
3091
 
2961
3092
  var isThereSubtitle = function isThereSubtitle() {
2962
- var _widget$current10, _widget$current11;
3093
+ var _widget$current11, _widget$current12;
2963
3094
 
2964
- return ((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.Subtitle) && ((_widget$current11 = widget.current) === null || _widget$current11 === void 0 ? void 0 : _widget$current11.Subtitle.length) > 0;
3095
+ return ((_widget$current11 = widget.current) === null || _widget$current11 === void 0 ? void 0 : _widget$current11.Subtitle) && ((_widget$current12 = widget.current) === null || _widget$current12 === void 0 ? void 0 : _widget$current12.Subtitle.length) > 0;
2965
3096
  };
2966
3097
 
2967
3098
  var tableHintMessage = function tableHintMessage() {
2968
3099
  return React__default.createElement("span", {
2969
3100
  className: "table-hint-container " + (isTitleAligmentRight() ? "padding-left-12" : "")
2970
- }, React__default.createElement("span", null, "Showing the first 100 rows"), !props.isInEditMode && !props.isPreviewModeActive && React__default.createElement(React__default.Fragment, null, React__default.createElement("span", null, "("), React__default.createElement("span", {
3101
+ }, React__default.createElement("span", null, "Showing the first 100 rows"), !props.isInEditMode && !props.isPreviewModeActive && isTableWidget() && React__default.createElement(React__default.Fragment, null, React__default.createElement("span", null, "("), React__default.createElement("span", {
2971
3102
  onClick: drilldownToTableData,
2972
3103
  className: "show-more-records"
2973
3104
  }, " Show More Records "), React__default.createElement("span", null, ")")));
@@ -2984,11 +3115,11 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
2984
3115
  key: triggerId,
2985
3116
  className: "widget-header"
2986
3117
  }, React__default.createElement("div", {
2987
- className: "header-contents " + (isTableWidget() ? "border-bottom-light-white" : "")
2988
- }, isTitleAligmentRight() && isTableWidget() && tableHintMessage(), React__default.createElement("div", {
3118
+ className: "header-contents " + (isTableOrPivotWidget() ? "border-bottom-light-white" : "")
3119
+ }, isTitleAligmentRight() && isTableOrPivotWidget() && tableHintMessage(), React__default.createElement("div", {
2989
3120
  style: {
2990
3121
  cursor: props.isInEditMode ? "move" : "default",
2991
- justifyContent: isTableWidget() ? getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined) : undefined,
3122
+ justifyContent: isTableOrPivotWidget() ? getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined) : undefined,
2992
3123
  flexDirection: isTitleAligmentRight() ? "row-reverse" : "row"
2993
3124
  },
2994
3125
  className: getwidgetTitlesContainer()
@@ -3006,7 +3137,7 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
3006
3137
  color: getCSSPropertyValue(widget.current, 'TitleFontColor', ''),
3007
3138
  textAlign: getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined)
3008
3139
  }
3009
- }, (_widget$current12 = widget.current) === null || _widget$current12 === void 0 ? void 0 : _widget$current12.Title),
3140
+ }, (_widget$current13 = widget.current) === null || _widget$current13 === void 0 ? void 0 : _widget$current13.Title),
3010
3141
  position: ['top center'],
3011
3142
  arrowStyle: {
3012
3143
  color: '#262626'
@@ -3015,7 +3146,7 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
3015
3146
  on: ['hover', 'focus']
3016
3147
  }, React__default.createElement("span", {
3017
3148
  className: "widget-title-tooltip-text"
3018
- }, (_widget$current13 = widget.current) === null || _widget$current13 === void 0 ? void 0 : _widget$current13.Title))), isTableWidget() && isThereTitle() && isThereSubtitle() && React__default.createElement("div", {
3149
+ }, (_widget$current14 = widget.current) === null || _widget$current14 === void 0 ? void 0 : _widget$current14.Title))), isTableOrPivotWidget() && isThereTitle() && isThereSubtitle() && React__default.createElement("div", {
3019
3150
  className: "titles-vertical-seeparator"
3020
3151
  }), React__default.createElement("div", {
3021
3152
  className: isThereSubtitle() ? "subtitle" : "subtitle margin-top-4",
@@ -3023,9 +3154,9 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
3023
3154
  fontSize: getCSSPropertyValue(widget.current, 'SubtitleFontSize', 'px'),
3024
3155
  textAlign: getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined),
3025
3156
  color: getCSSPropertyValue(widget.current, 'SubtitleFontColor', ''),
3026
- minWidth: isThereSubtitle() && isTableWidget() ? '5%' : undefined
3157
+ minWidth: isThereSubtitle() && isTableOrPivotWidget() ? '5%' : undefined
3027
3158
  }
3028
- }, (_widget$current14 = widget.current) === null || _widget$current14 === void 0 ? void 0 : _widget$current14.Subtitle)), !isTitleAligmentRight() && isTableWidget() && tableHintMessage(), props.isInEditMode && React__default.createElement("div", {
3159
+ }, (_widget$current15 = widget.current) === null || _widget$current15 === void 0 ? void 0 : _widget$current15.Subtitle)), !isTitleAligmentRight() && isTableOrPivotWidget() && tableHintMessage(), props.isInEditMode && React__default.createElement("div", {
3029
3160
  className: isThereTitle() ? "widget-options-container" : "widget-options-container margin-top-6"
3030
3161
  }, React__default.createElement(SvgEditIcon, {
3031
3162
  onClick: function onClick() {