dtable-statistic 4.0.2-test-2

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.
Files changed (210) hide show
  1. package/README.md +3 -0
  2. package/es/api/dtable-db-api.js +43 -0
  3. package/es/assets/css/color-picker.css +53 -0
  4. package/es/assets/css/color-rules-popover.css +144 -0
  5. package/es/assets/css/color-theme-dialog.css +40 -0
  6. package/es/assets/css/dashboard.css +562 -0
  7. package/es/assets/css/dialog.css +415 -0
  8. package/es/assets/css/mobile-dashboard.module.css +91 -0
  9. package/es/assets/css/slider.css +77 -0
  10. package/es/assets/css/statistic-chart.module.css +11 -0
  11. package/es/assets/css/statistic-custom-title.module.css +3 -0
  12. package/es/assets/css/statistic-custom.module.css +4 -0
  13. package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
  14. package/es/assets/css/statistic-time-picker.module.css +21 -0
  15. package/es/assets/css/theme.css +61 -0
  16. package/es/assets/images/icon.png +0 -0
  17. package/es/calculator/base-calculator.js +111 -0
  18. package/es/calculator/basic-chart-calculator.js +571 -0
  19. package/es/calculator/combination-calculator.js +296 -0
  20. package/es/calculator/compare-bar-calculator.js +291 -0
  21. package/es/calculator/completeness-calculator.js +307 -0
  22. package/es/calculator/copy-value.js +47 -0
  23. package/es/calculator/dashboard-calculator.js +146 -0
  24. package/es/calculator/heat-map-calculator.js +225 -0
  25. package/es/calculator/horizontal-bar-calculator.js +100 -0
  26. package/es/calculator/index.js +88 -0
  27. package/es/calculator/map-calculator.js +169 -0
  28. package/es/calculator/mirror-calculator.js +217 -0
  29. package/es/calculator/number-card-calculator.js +135 -0
  30. package/es/calculator/pivot-table-calculator.js +810 -0
  31. package/es/calculator/scatter-calculator.js +150 -0
  32. package/es/calculator/thread-manager.js +70 -0
  33. package/es/calculator/trend-calculator.js +204 -0
  34. package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
  35. package/es/calculator/workers/calculator.worker.js +22 -0
  36. package/es/calculator/workers/card-calculator-worker.js +28 -0
  37. package/es/calculator/workers/combination-calculator-worker.js +257 -0
  38. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
  39. package/es/calculator/workers/completeness-calculator-worker.js +153 -0
  40. package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
  41. package/es/calculator/workers/mirror-calculator-worker.js +132 -0
  42. package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
  43. package/es/calculator/workers/scatter-calculator-worker.js +67 -0
  44. package/es/calculator/workers/trend-calculator-worker.js +93 -0
  45. package/es/calculator/world-map-calculator.js +193 -0
  46. package/es/components/common-add-tool.js +19 -0
  47. package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
  48. package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
  49. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
  50. package/es/components/dialog/color-theme-dialog.js +71 -0
  51. package/es/components/dialog/enlarged-chart-dialog.js +73 -0
  52. package/es/components/dialog/new-table-dialog.js +113 -0
  53. package/es/components/dialog/new-view-dialog.js +87 -0
  54. package/es/components/dialog/rename-view-dialog.js +87 -0
  55. package/es/components/dialog/statistic-record-dialog/index.css +114 -0
  56. package/es/components/dialog/statistic-record-dialog/index.js +174 -0
  57. package/es/components/dialog/table-select-dialog.js +93 -0
  58. package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
  59. package/es/components/dtable-popover.js +109 -0
  60. package/es/components/dtable-search-input.js +137 -0
  61. package/es/components/dtable-select.js +104 -0
  62. package/es/components/index.js +11 -0
  63. package/es/components/loading.js +8 -0
  64. package/es/components/modal-portal.js +36 -0
  65. package/es/components/popover/color-rules/color-rule.js +179 -0
  66. package/es/components/popover/color-rules/index.js +87 -0
  67. package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
  68. package/es/components/popover/color-rules/rule-filters/index.css +214 -0
  69. package/es/components/popover/color-rules/rule-filters/index.js +97 -0
  70. package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
  71. package/es/components/popover/color-rules-popover.js +213 -0
  72. package/es/components/popover/color-selector-popover.js +85 -0
  73. package/es/components/seatable-radio/index.css +51 -0
  74. package/es/components/seatable-radio/index.js +28 -0
  75. package/es/components/select/index.js +2 -0
  76. package/es/components/select/option-group.css +104 -0
  77. package/es/components/select/option-group.js +225 -0
  78. package/es/components/select/option.js +51 -0
  79. package/es/components/select/select.css +211 -0
  80. package/es/components/select/select.js +157 -0
  81. package/es/components/toast/alert.js +130 -0
  82. package/es/components/toast/index.js +3 -0
  83. package/es/components/toast/toast.js +164 -0
  84. package/es/components/toast/toastManager.js +150 -0
  85. package/es/components/toast/toaster.js +64 -0
  86. package/es/constants/color-rules.js +8 -0
  87. package/es/constants/dtable-select-style.js +61 -0
  88. package/es/constants/event-types.js +1 -0
  89. package/es/constants/index.js +501 -0
  90. package/es/constants/key-codes.js +102 -0
  91. package/es/constants/zIndexes.js +1 -0
  92. package/es/custom-g2.js +614 -0
  93. package/es/dashboard.js +408 -0
  94. package/es/desktop-dashboard.js +299 -0
  95. package/es/index.js +33 -0
  96. package/es/locale/index.js +17 -0
  97. package/es/locale/lang/de.js +237 -0
  98. package/es/locale/lang/en.js +237 -0
  99. package/es/locale/lang/fr.js +237 -0
  100. package/es/locale/lang/zh_CN.js +237 -0
  101. package/es/mobile-dashboard.js +103 -0
  102. package/es/model/collaborators.js +11 -0
  103. package/es/model/stat-item.js +340 -0
  104. package/es/model/statistic-dashboard.js +8 -0
  105. package/es/service/chart-service.js +192 -0
  106. package/es/service/dashboard-service.js +415 -0
  107. package/es/stat-editor/chart-name-editor.js +75 -0
  108. package/es/stat-editor/index.js +74 -0
  109. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
  110. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
  111. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
  112. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
  113. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
  114. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
  115. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
  116. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
  117. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
  118. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
  119. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
  120. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
  121. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
  122. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
  123. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
  124. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
  125. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
  126. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
  127. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
  128. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
  129. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
  130. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
  131. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
  132. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
  133. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
  134. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
  135. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
  136. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
  137. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
  138. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
  139. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
  140. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
  141. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
  143. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
  144. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
  145. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
  146. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
  147. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
  148. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
  149. package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
  150. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
  151. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
  152. package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
  153. package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
  154. package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
  155. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
  156. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
  157. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
  158. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
  159. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
  160. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
  161. package/es/stat-list/chart-preview.js +139 -0
  162. package/es/stat-list/index.js +275 -0
  163. package/es/stat-view/area-chart.js +521 -0
  164. package/es/stat-view/bar-chart.js +568 -0
  165. package/es/stat-view/base-chart.js +44 -0
  166. package/es/stat-view/basic-number-card.js +255 -0
  167. package/es/stat-view/combination-chart.js +558 -0
  168. package/es/stat-view/compare-chart.js +485 -0
  169. package/es/stat-view/completeness-chart.js +389 -0
  170. package/es/stat-view/custom-bar.js +433 -0
  171. package/es/stat-view/dashboard-chart.js +317 -0
  172. package/es/stat-view/heat-map.js +501 -0
  173. package/es/stat-view/horizontal-bar-chart.js +569 -0
  174. package/es/stat-view/index.js +183 -0
  175. package/es/stat-view/line-chart.js +505 -0
  176. package/es/stat-view/map.js +428 -0
  177. package/es/stat-view/mirror.js +285 -0
  178. package/es/stat-view/pie-chart.js +326 -0
  179. package/es/stat-view/pivot-table/index.js +206 -0
  180. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
  181. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
  182. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
  183. package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
  184. package/es/stat-view/ring-chart.js +416 -0
  185. package/es/stat-view/scatter-chart.js +367 -0
  186. package/es/stat-view/treemap-chart.js +318 -0
  187. package/es/stat-view/trend-chart.js +299 -0
  188. package/es/stat-view/world-map.js +443 -0
  189. package/es/tabs/index.js +252 -0
  190. package/es/tabs/statistic-tabs.module.css +154 -0
  191. package/es/tabs/tab.js +167 -0
  192. package/es/utils/basic-chart-utils.js +24 -0
  193. package/es/utils/cell-format.js +110 -0
  194. package/es/utils/cell-value.js +27 -0
  195. package/es/utils/collaborator.js +31 -0
  196. package/es/utils/color-utils.js +112 -0
  197. package/es/utils/column-utils.js +18 -0
  198. package/es/utils/column.js +13 -0
  199. package/es/utils/common-utils.js +303 -0
  200. package/es/utils/date-format.js +65 -0
  201. package/es/utils/export-table-utils.js +632 -0
  202. package/es/utils/index.js +26 -0
  203. package/es/utils/object.js +26 -0
  204. package/es/utils/row-utils.js +115 -0
  205. package/es/utils/search.js +67 -0
  206. package/es/utils/sql-utils.js +293 -0
  207. package/es/utils/stat-utils.js +353 -0
  208. package/es/utils/trend-utils.js +136 -0
  209. package/index.js +1 -0
  210. package/package.json +188 -0
@@ -0,0 +1,164 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { PureComponent } from 'react';
7
+ import intl from 'react-intl-universal';
8
+ import { TableUtils } from 'dtable-store';
9
+ import { isMobile } from '../../utils';
10
+ import { EMPTY_NAME, TITLE_TOTAL } from '../../constants';
11
+ import styles from './statistic-pivot-table.module.css';
12
+ var OneDimensionTableWithNumericColumns = /*#__PURE__*/function (_PureComponent) {
13
+ _inherits(OneDimensionTableWithNumericColumns, _PureComponent);
14
+ var _super = _createSuper(OneDimensionTableWithNumericColumns);
15
+ function OneDimensionTableWithNumericColumns() {
16
+ var _this;
17
+ _classCallCheck(this, OneDimensionTableWithNumericColumns);
18
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ args[_key] = arguments[_key];
20
+ }
21
+ _this = _super.call.apply(_super, [this].concat(args));
22
+ _this.toggleRecords = function (cell) {
23
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
24
+ _ref$isColumn = _ref.isColumn,
25
+ isColumn = _ref$isColumn === void 0 ? false : _ref$isColumn,
26
+ _ref$isCurrentView = _ref.isCurrentView,
27
+ isCurrentView = _ref$isCurrentView === void 0 ? false : _ref$isCurrentView;
28
+ if (isMobile) return;
29
+ _this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem, {
30
+ isColumn: isColumn,
31
+ isCurrentView: isCurrentView
32
+ });
33
+ };
34
+ _this.renderHeader = function (_ref2) {
35
+ var table = _ref2.table,
36
+ groupbyColumn = _ref2.groupbyColumn;
37
+ var _this$props = _this.props,
38
+ pivotResult = _this$props.pivotResult,
39
+ statItem = _this$props.statItem;
40
+ var column_groupby_column_key = statItem.column_groupby_column_key;
41
+ var statisticTableColumns = table.columns;
42
+ var columnGroupbyColumn = TableUtils.getTableColumnByKey(table, column_groupby_column_key);
43
+ var groupName = groupbyColumn.name;
44
+ var _ref3 = columnGroupbyColumn || {},
45
+ rowGroupName = _ref3.name;
46
+ var pivot_columns = pivotResult.pivot_columns;
47
+ return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
48
+ className: "pivot-table-header"
49
+ }, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
50
+ var key = item.key;
51
+ var column = statisticTableColumns.find(function (column) {
52
+ return column.key === key;
53
+ });
54
+ return /*#__PURE__*/React.createElement("th", {
55
+ className: 'pivot-table-header',
56
+ key: "pivot-column-".concat(index)
57
+ }, /*#__PURE__*/React.createElement("div", null, column.name));
58
+ })));
59
+ };
60
+ _this.renderRows = function (_ref4) {
61
+ var table = _ref4.table;
62
+ var _this$props2 = _this.props,
63
+ pivotResult = _this$props2.pivotResult,
64
+ statItem = _this$props2.statItem,
65
+ getSummaryValueDisplayString = _this$props2.getSummaryValueDisplayString;
66
+ var statisticTableColumns = table.columns;
67
+ var _statItem$display_tot = statItem.display_total,
68
+ display_total = _statItem$display_tot === void 0 ? true : _statItem$display_tot;
69
+ var pivot_rows = pivotResult.pivot_rows,
70
+ pivot_columns = pivotResult.pivot_columns,
71
+ pivot_columns_total = pivotResult.pivot_columns_total;
72
+ var pivotColumnCells = [];
73
+ return /*#__PURE__*/React.createElement("tbody", null, pivot_rows.map(function (rowItem, rowIdx) {
74
+ var name = rowItem.name,
75
+ total = rowItem.total,
76
+ rows = rowItem.rows;
77
+ if (!Array.isArray(pivot_columns)) {
78
+ pivotColumnCells[rowIdx] = rowItem.rows || [];
79
+ }
80
+ return /*#__PURE__*/React.createElement("tr", {
81
+ key: 'table-row' + rowIdx
82
+ }, /*#__PURE__*/React.createElement("td", {
83
+ className: 'pivot-row-name'
84
+ }, /*#__PURE__*/React.createElement("div", null, !name || name === 0 ? intl.get(EMPTY_NAME) : name)), Array.isArray(pivot_columns) && pivot_columns.map(function (columnMap, cellIdx) {
85
+ var key = columnMap.key,
86
+ method = columnMap.method;
87
+ if (Array.isArray(rows) && rows.length > 0) {
88
+ if (pivotColumnCells[cellIdx]) {
89
+ var _pivotColumnCells$cel;
90
+ (_pivotColumnCells$cel = pivotColumnCells[cellIdx]).push.apply(_pivotColumnCells$cel, _toConsumableArray(rows));
91
+ } else {
92
+ pivotColumnCells[cellIdx] = _toConsumableArray(rows);
93
+ }
94
+ }
95
+ var column = statisticTableColumns.find(function (item) {
96
+ return item.key === key;
97
+ });
98
+ var displayValue = getSummaryValueDisplayString(column, total[key + method], method);
99
+ var isValidDisplayValue = _this.props.isValidValue(displayValue);
100
+ return /*#__PURE__*/React.createElement("td", {
101
+ className: "".concat(styles['pivot-cell'], " ").concat(isValidDisplayValue ? '' : styles['pivot-empty-cell']),
102
+ key: "table-cell-".concat(cellIdx),
103
+ onClick: function onClick() {
104
+ return _this.toggleRecords(rowItem);
105
+ },
106
+ title: isValidDisplayValue ? displayValue : ''
107
+ }, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null));
108
+ }));
109
+ }), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
110
+ className: 'pivot-column-total'
111
+ }, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
112
+ var pivotColumnCell = pivotColumnCells[index];
113
+ var pivotColumnTotal = pivot_columns_total[c.key + c.method];
114
+ var column = statisticTableColumns.find(function (column) {
115
+ return column.key === c.key;
116
+ });
117
+ var displayValue = getSummaryValueDisplayString(column, pivotColumnTotal, c.method);
118
+ var isValidDisplayValue = _this.props.isValidValue(displayValue);
119
+ return /*#__PURE__*/React.createElement("td", {
120
+ className: "".concat(styles['pivot-cell'], " ").concat(isValidDisplayValue ? '' : styles['pivot-empty-cell']),
121
+ key: "total-cell-".concat(index),
122
+ title: isValidDisplayValue ? displayValue : '',
123
+ onClick: function onClick() {
124
+ return _this.toggleRecords({
125
+ name: c.key,
126
+ rows: pivotColumnCell
127
+ }, {
128
+ isCurrentView: true
129
+ });
130
+ }
131
+ }, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null));
132
+ })));
133
+ };
134
+ return _this;
135
+ }
136
+ _createClass(OneDimensionTableWithNumericColumns, [{
137
+ key: "render",
138
+ value: function render() {
139
+ var _this$props3 = this.props,
140
+ statItem = _this$props3.statItem,
141
+ isPreview = _this$props3.isPreview,
142
+ textColor = _this$props3.textColor,
143
+ getTableById = _this$props3.getTableById;
144
+ var table_id = statItem.table_id,
145
+ groupby_column_key = statItem.groupby_column_key;
146
+ var table = getTableById(table_id);
147
+ var groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
148
+ if (!groupbyColumn) return '';
149
+ return /*#__PURE__*/React.createElement("table", {
150
+ style: {
151
+ color: textColor
152
+ },
153
+ className: "".concat(isPreview ? styles['preview-pivot-table'] : styles['large-pivot-table'], " ").concat(styles['pivot-table'])
154
+ }, this.renderHeader({
155
+ table: table,
156
+ groupbyColumn: groupbyColumn
157
+ }), this.renderRows({
158
+ table: table
159
+ }));
160
+ }
161
+ }]);
162
+ return OneDimensionTableWithNumericColumns;
163
+ }(PureComponent);
164
+ export default OneDimensionTableWithNumericColumns;
@@ -0,0 +1,132 @@
1
+ .pivot-table-container {
2
+ height: 100%;
3
+ width: 100%;
4
+ padding: 15px 20px;
5
+ box-sizing: border-box;
6
+ overflow: auto;
7
+ }
8
+
9
+ .pivot-table {
10
+ width: 100%;
11
+ margin: 0 auto;
12
+ position: relative;
13
+ table-layout: fixed;
14
+ }
15
+
16
+ .pivot-table tr {
17
+ border-bottom: 1px solid #ccc;
18
+ text-align: center;
19
+ }
20
+
21
+ .pivot-table thead {
22
+ border-top: 1px solid #ccc;
23
+ font-size: 13px;
24
+ }
25
+
26
+ .large-pivot-table td {
27
+ padding: 10px;
28
+ border-right: 1px solid #ccc;
29
+ border-left: 1px solid #ccc;
30
+ overflow: hidden;
31
+ min-width: 100px;
32
+ width: 150px;
33
+ max-width: 150px;
34
+ font-weight: normal;
35
+ text-overflow: ellipsis;
36
+ white-space: nowrap;
37
+ }
38
+
39
+ .large-pivot-table th {
40
+ padding: 10px;
41
+ border-right: 1px solid #ccc;
42
+ border-left: 1px solid #ccc;
43
+ overflow: hidden;
44
+ min-width: 100px;
45
+ width: 150px;
46
+ max-width: 150px;
47
+ font-weight: normal;
48
+ text-overflow: ellipsis;
49
+ white-space: nowrap;
50
+ }
51
+
52
+ .preview-pivot-table td,
53
+ .preview-pivot-table th {
54
+ padding: 5px;
55
+ border-right: 1px solid #ccc;
56
+ border-left: 1px solid #ccc;
57
+ overflow: hidden;
58
+ font-weight: normal;
59
+ }
60
+
61
+ .pivot-table td>div, .pivot-table th>div {
62
+ white-space: nowrap;
63
+ text-overflow: ellipsis;
64
+ overflow: hidden;
65
+ font-size: 13px;
66
+ max-width: 100%;
67
+ }
68
+
69
+ .pivot-table .column-title {
70
+ caption-side: top;
71
+ text-align: center;
72
+ color: inherit;
73
+ padding: 0;
74
+ }
75
+
76
+ .pivot-table .row-title {
77
+ position: absolute;
78
+ padding: 0;
79
+ transform: rotate(-90deg);
80
+ width: 100px;
81
+ left: -60px;
82
+ top: 50%;
83
+ overflow: hidden;
84
+ white-space: nowrap;
85
+ text-overflow: ellipsis;
86
+ text-align: center;
87
+ color: inherit;
88
+ }
89
+
90
+ .pivot-table .pivot-empty-cell i {
91
+ display: inline-block;
92
+ height: 6px;
93
+ width: 16px;
94
+ border-radius: 6px;
95
+ background: #f1f1f1;
96
+ }
97
+
98
+ .pivot-summary-multiple-columns-th {
99
+ width: 100%;
100
+ min-width: 100%;
101
+ border: 0px;
102
+ padding: 0px !important;
103
+ }
104
+
105
+ .pivot-summary-multiple-columns-td {
106
+ padding: 0px !important
107
+ }
108
+
109
+ .pivot-summary-multiple-columns-div {
110
+ display: flex;
111
+ }
112
+
113
+ .pivot-summary-multiple-columns-div div {
114
+ padding: 10px;
115
+ flex: 1;
116
+ }
117
+
118
+ .pivot-summary-multiple-columns-div :not(:last-child) {
119
+ border-right: 1px solid #ccc;
120
+ }
121
+
122
+ .multiple-pivot-empty-cell {
123
+ display: inline-block;
124
+ height: 6px;
125
+ width: 16px;
126
+ border-radius: 6px;
127
+ background: #f1f1f1;
128
+ }
129
+
130
+ .pivot-cell:hover {
131
+ cursor: pointer;
132
+ }
@@ -0,0 +1,344 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import React, { PureComponent } from 'react';
8
+ import intl from 'react-intl-universal';
9
+ import { CellType, isNumber, TableUtils, Views } from 'dtable-store';
10
+ import { isMobile } from '../../utils';
11
+ import { EMPTY_NAME, TITLE_TOTAL } from '../../constants';
12
+ import styles from './statistic-pivot-table.module.css';
13
+ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
14
+ _inherits(TwoDimensionTable, _PureComponent);
15
+ var _super = _createSuper(TwoDimensionTable);
16
+ function TwoDimensionTable() {
17
+ var _this;
18
+ _classCallCheck(this, TwoDimensionTable);
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+ _this = _super.call.apply(_super, [this].concat(args));
23
+ _this.toggleRecords = function (cell) {
24
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
25
+ _ref$isColumn = _ref.isColumn,
26
+ isColumn = _ref$isColumn === void 0 ? false : _ref$isColumn,
27
+ _ref$isRow = _ref.isRow,
28
+ isRow = _ref$isRow === void 0 ? false : _ref$isRow;
29
+ if (isMobile) return;
30
+ _this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem, {
31
+ isColumn: isColumn,
32
+ isRow: isRow
33
+ });
34
+ };
35
+ _this.onClickTotals = function (recordsList, _ref2) {
36
+ var isCurrentView = _ref2.isCurrentView;
37
+ if (isMobile) return;
38
+ var _this$props = _this.props,
39
+ getTableById = _this$props.getTableById,
40
+ statItem = _this$props.statItem;
41
+ var table_id = statItem.table_id,
42
+ view_id = statItem.view_id;
43
+ var table = getTableById(table_id);
44
+ var view = Views.getViewById(table.views, view_id);
45
+ var rows = [];
46
+ if (!Views.isArchiveView(view)) {
47
+ rows = recordsList.flat();
48
+ }
49
+ _this.props.toggleStatisticRecordsDialog({
50
+ rows: rows
51
+ }, statItem, {
52
+ isCurrentView: isCurrentView
53
+ });
54
+ };
55
+ _this.getNumberValue = function (val) {
56
+ if (isNumber(val)) {
57
+ return val;
58
+ }
59
+ return 0;
60
+ };
61
+ _this.getCells = function (row, summaryColumn) {
62
+ var pivotResult = _this.props.pivotResult;
63
+ var pivot_columns = pivotResult.pivot_columns,
64
+ pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns,
65
+ formulaRows = pivotResult.formulaRows,
66
+ _pivotResult$isSqlQue = pivotResult.isSqlQuery,
67
+ isSqlQuery = _pivotResult$isSqlQue === void 0 ? false : _pivotResult$isSqlQue;
68
+ var cells = row.cells;
69
+ if (!Array.isArray(pivot_columns)) {
70
+ return [];
71
+ }
72
+ return pivot_columns.map(function (item) {
73
+ var cell = cells[item.key];
74
+ var rowData = cell && cell.rows;
75
+ var summary_multiple_columns = pivot_summary_multiple_columns.map(function (columns) {
76
+ if (Array.isArray(rowData)) {
77
+ var sum = 0;
78
+ rowData.forEach(function (rowDataItem) {
79
+ if (!isSqlQuery) {
80
+ if (columns.type === CellType.FORMULA) {
81
+ var formulaRow = formulaRows[rowDataItem._id];
82
+ sum += _this.getNumberValue(formulaRow[columns.key]);
83
+ return;
84
+ }
85
+ sum += _this.getNumberValue(rowDataItem[columns.key]);
86
+ return;
87
+ }
88
+ sum += _this.getNumberValue(rowDataItem[columns.sqlKey]);
89
+ });
90
+ return sum;
91
+ }
92
+ return 0;
93
+ });
94
+ return _objectSpread(_objectSpread({}, cells[item.key]), {}, {
95
+ group_original_name: item.original_name,
96
+ group_name: item.key,
97
+ column: summaryColumn,
98
+ summary_multiple_columns: summary_multiple_columns
99
+ });
100
+ });
101
+ };
102
+ _this.renderHeader = function (_ref3) {
103
+ var groupbyColumn = _ref3.groupbyColumn,
104
+ columnGroupbyColumn = _ref3.columnGroupbyColumn;
105
+ var _this$props2 = _this.props,
106
+ pivotResult = _this$props2.pivotResult,
107
+ statItem = _this$props2.statItem;
108
+ var column_groupby_column_key = statItem.column_groupby_column_key,
109
+ column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
110
+ _statItem$display_tot = statItem.display_total,
111
+ display_total = _statItem$display_tot === void 0 ? true : _statItem$display_tot;
112
+ var groupName = groupbyColumn.name;
113
+ var _ref4 = columnGroupbyColumn || {},
114
+ rowGroupName = _ref4.name;
115
+ var pivot_columns = pivotResult.pivot_columns,
116
+ pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns;
117
+ var isMultipleColumnHeader = column_groupby_multiple_numeric_column && column_groupby_column_key && pivot_summary_multiple_columns.length !== 0;
118
+ return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
119
+ className: "pivot-table-header"
120
+ }, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
121
+ var key = item.key;
122
+ return /*#__PURE__*/React.createElement("th", {
123
+ className: 'pivot-table-header',
124
+ key: "pivot-column-".concat(index)
125
+ }, /*#__PURE__*/React.createElement("div", null, !key || key === 0 ? intl.get(EMPTY_NAME) : key));
126
+ }), display_total && /*#__PURE__*/React.createElement("th", {
127
+ className: 'pivot-table-header'
128
+ }, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL)))), isMultipleColumnHeader && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
129
+ className: "pivot-table-header"
130
+ }), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
131
+ return /*#__PURE__*/React.createElement("th", {
132
+ className: "pivot-table-header ".concat(styles['pivot-summary-multiple-columns-th']),
133
+ key: "pivot-column-".concat(index)
134
+ }, /*#__PURE__*/React.createElement("div", {
135
+ className: styles['pivot-summary-multiple-columns-div']
136
+ }, pivot_summary_multiple_columns.map(function (item, index) {
137
+ return /*#__PURE__*/React.createElement("div", {
138
+ key: index
139
+ }, item.column_name);
140
+ })));
141
+ }), display_total && /*#__PURE__*/React.createElement("th", {
142
+ className: "pivot-table-header ".concat(styles['pivot-empty-cell'])
143
+ })));
144
+ };
145
+ _this.renderRows = function (_ref5) {
146
+ var table = _ref5.table;
147
+ var _this$props3 = _this.props,
148
+ pivotResult = _this$props3.pivotResult,
149
+ statItem = _this$props3.statItem,
150
+ getSummaryValueDisplayString = _this$props3.getSummaryValueDisplayString;
151
+ var summary_column_key = statItem.summary_column_key,
152
+ summary_method = statItem.summary_method,
153
+ column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
154
+ _statItem$display_tot2 = statItem.display_total,
155
+ display_total = _statItem$display_tot2 === void 0 ? true : _statItem$display_tot2;
156
+ var pivot_rows = pivotResult.pivot_rows,
157
+ pivot_columns = pivotResult.pivot_columns,
158
+ pivot_columns_total = pivotResult.pivot_columns_total,
159
+ pivot_table_total = pivotResult.pivot_table_total,
160
+ pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns,
161
+ formulaRows = pivotResult.formulaRows,
162
+ _pivotResult$isSqlQue2 = pivotResult.isSqlQuery,
163
+ isSqlQuery = _pivotResult$isSqlQue2 === void 0 ? false : _pivotResult$isSqlQue2;
164
+ var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
165
+ var allTotalDisplay = column_groupby_multiple_numeric_column ? 0 : getSummaryValueDisplayString(summaryColumn, pivot_table_total, summary_method);
166
+ var isValidAllTotalDisplay = _this.props.isValidValue(allTotalDisplay);
167
+ var pivotColumnCells = [];
168
+ return /*#__PURE__*/React.createElement("tbody", null, pivot_rows.map(function (rowItem, rowIdx) {
169
+ var name = rowItem.name,
170
+ total = rowItem.total;
171
+ var cells = _this.getCells(rowItem, summaryColumn);
172
+ var pivotRowCells = [];
173
+ if (!Array.isArray(pivot_columns)) {
174
+ pivotColumnCells[rowIdx] = rowItem.rows || [];
175
+ }
176
+ var summaryDisplayValue = getSummaryValueDisplayString(summaryColumn, total, summary_method);
177
+ if (column_groupby_multiple_numeric_column) {
178
+ summaryDisplayValue = 0;
179
+ }
180
+ var isValidSummaryDisplayValue = _this.props.isValidValue(summaryDisplayValue);
181
+ return /*#__PURE__*/React.createElement("tr", {
182
+ key: 'table-row' + rowIdx
183
+ }, /*#__PURE__*/React.createElement("td", {
184
+ className: 'pivot-row-name'
185
+ }, /*#__PURE__*/React.createElement("div", null, !name || name === 0 ? intl.get(EMPTY_NAME) : name)), Array.isArray(cells) && cells.map(function (c, cellIdx) {
186
+ if (c && Array.isArray(c.rows) && c.rows.length > 0) {
187
+ pivotRowCells.push.apply(pivotRowCells, _toConsumableArray(c.rows));
188
+ if (pivotColumnCells[cellIdx]) {
189
+ var _pivotColumnCells$cel;
190
+ (_pivotColumnCells$cel = pivotColumnCells[cellIdx]).push.apply(_pivotColumnCells$cel, _toConsumableArray(c.rows));
191
+ } else {
192
+ pivotColumnCells[cellIdx] = _toConsumableArray(c.rows);
193
+ }
194
+ }
195
+ if (column_groupby_multiple_numeric_column) {
196
+ var summary_multiple_columns = c.summary_multiple_columns;
197
+ summary_multiple_columns.forEach(function (item) {
198
+ summaryDisplayValue += _this.getNumberValue(item);
199
+ });
200
+ return /*#__PURE__*/React.createElement("td", {
201
+ className: "".concat(styles['pivot-cell'], " ").concat(styles['pivot-summary-multiple-columns-td']),
202
+ key: "table-cell-".concat(cellIdx),
203
+ onClick: function onClick() {
204
+ return _this.toggleRecords({
205
+ rows: c.rows,
206
+ name: name,
207
+ rowItem: rowItem,
208
+ group_name: c.group_name,
209
+ group_original_name: c.group_original_name,
210
+ original_name: rowItem.original_name
211
+ });
212
+ }
213
+ }, /*#__PURE__*/React.createElement("div", {
214
+ className: styles['pivot-summary-multiple-columns-div']
215
+ }, summary_multiple_columns.map(function (label, index) {
216
+ return /*#__PURE__*/React.createElement("div", {
217
+ key: index
218
+ }, label === 0 ? /*#__PURE__*/React.createElement("i", {
219
+ className: styles['multiple-pivot-empty-cell']
220
+ }) : label);
221
+ })), /*#__PURE__*/React.createElement("span", null));
222
+ }
223
+ var displayValue = getSummaryValueDisplayString(c.column, c.total, summary_method);
224
+ var isValidDisplayValue = _this.props.isValidValue(displayValue);
225
+ return /*#__PURE__*/React.createElement("td", {
226
+ className: "".concat(styles['pivot-cell'], " ").concat(isValidDisplayValue ? '' : styles['pivot-empty-cell']),
227
+ key: "table-cell-".concat(cellIdx),
228
+ title: isValidDisplayValue ? displayValue : '',
229
+ onClick: function onClick() {
230
+ return _this.toggleRecords({
231
+ rows: c.rows,
232
+ name: name,
233
+ rowItem: rowItem,
234
+ group_name: c.group_name,
235
+ group_original_name: c.group_original_name,
236
+ original_name: rowItem.original_name
237
+ });
238
+ }
239
+ }, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", null));
240
+ }), display_total && /*#__PURE__*/React.createElement("td", {
241
+ className: "".concat(styles['pivot-cell'], " ").concat(isValidSummaryDisplayValue ? '' : styles['pivot-empty-cell']),
242
+ title: isValidSummaryDisplayValue ? summaryDisplayValue : '',
243
+ onClick: function onClick() {
244
+ return _this.toggleRecords({
245
+ rows: Array.isArray(cells) && cells.length > 0 ? pivotRowCells : rowItem.rows,
246
+ name: name,
247
+ rowItem: rowItem,
248
+ original_name: rowItem.original_name
249
+ }, {
250
+ isRow: true
251
+ });
252
+ }
253
+ }, isValidSummaryDisplayValue ? /*#__PURE__*/React.createElement("div", null, summaryDisplayValue) : /*#__PURE__*/React.createElement("i", null)));
254
+ }), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
255
+ className: 'pivot-column-total'
256
+ }, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
257
+ var pivotColumnCell = pivotColumnCells[index] || [];
258
+ var pivotColumnTotal = pivot_columns_total[c.key];
259
+ var totalDisplayValue = getSummaryValueDisplayString(summaryColumn, pivotColumnTotal, summary_method);
260
+ var isValidTotalDisplayValue = _this.props.isValidValue(totalDisplayValue);
261
+ if (column_groupby_multiple_numeric_column) {
262
+ var total = 0;
263
+ pivotColumnCell.forEach(function (item) {
264
+ pivot_summary_multiple_columns.forEach(function (jtem) {
265
+ var type = jtem.type,
266
+ key = jtem.key,
267
+ sqlKey = jtem.sqlKey;
268
+ if (!isSqlQuery) {
269
+ if (type === CellType.FORMULA) {
270
+ var formulaRow = formulaRows[item._id];
271
+ total += _this.getNumberValue(formulaRow[key]);
272
+ return;
273
+ }
274
+ total += _this.getNumberValue(item[key]);
275
+ return;
276
+ }
277
+ total += _this.getNumberValue(item[sqlKey]);
278
+ });
279
+ });
280
+ totalDisplayValue = total;
281
+ allTotalDisplay += total;
282
+ }
283
+ return /*#__PURE__*/React.createElement("td", {
284
+ className: "".concat(styles['pivot-cell'], " ").concat(isValidTotalDisplayValue ? '' : styles['pivot-empty-cell']),
285
+ key: "total-cell-".concat(index),
286
+ title: isValidTotalDisplayValue ? totalDisplayValue : '',
287
+ onClick: function onClick() {
288
+ return _this.toggleRecords({
289
+ group_name: c.key,
290
+ rows: pivotColumnCell,
291
+ group_original_name: c.original_name
292
+ }, {
293
+ isColumn: true
294
+ });
295
+ }
296
+ }, isValidTotalDisplayValue ? /*#__PURE__*/React.createElement("div", null, totalDisplayValue) : /*#__PURE__*/React.createElement("i", null));
297
+ }), /*#__PURE__*/React.createElement("td", {
298
+ className: "".concat(styles['pivot-cell'], " pivot-table-total ").concat(isValidAllTotalDisplay ? '' : styles['pivot-empty-cell']),
299
+ onClick: function onClick() {
300
+ return _this.onClickTotals(pivotColumnCells, {
301
+ isCurrentView: true
302
+ });
303
+ },
304
+ title: isValidAllTotalDisplay ? allTotalDisplay : ''
305
+ }, isValidAllTotalDisplay ? /*#__PURE__*/React.createElement("div", null, allTotalDisplay) : /*#__PURE__*/React.createElement("i", null))));
306
+ };
307
+ return _this;
308
+ }
309
+ _createClass(TwoDimensionTable, [{
310
+ key: "render",
311
+ value: function render() {
312
+ var _this$props4 = this.props,
313
+ pivotResult = _this$props4.pivotResult,
314
+ statItem = _this$props4.statItem,
315
+ isPreview = _this$props4.isPreview,
316
+ textColor = _this$props4.textColor,
317
+ getTableById = _this$props4.getTableById;
318
+ if (!pivotResult) return '';
319
+ var table_id = statItem.table_id,
320
+ groupby_column_key = statItem.groupby_column_key,
321
+ column_groupby_column_key = statItem.column_groupby_column_key;
322
+ var table = getTableById(table_id);
323
+ var groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key) || {};
324
+ var columnGroupbyColumn = TableUtils.getTableColumnByKey(table, column_groupby_column_key) || {};
325
+ return /*#__PURE__*/React.createElement("table", {
326
+ style: {
327
+ color: textColor
328
+ },
329
+ className: "".concat(isPreview ? styles['preview-pivot-table'] : styles['large-pivot-table'], " ").concat(styles['pivot-table'])
330
+ }, /*#__PURE__*/React.createElement("caption", {
331
+ className: styles['column-title']
332
+ }, columnGroupbyColumn.name), /*#__PURE__*/React.createElement("caption", {
333
+ className: styles['row-title']
334
+ }, groupbyColumn.name), this.renderHeader({
335
+ groupbyColumn: groupbyColumn,
336
+ columnGroupbyColumn: columnGroupbyColumn
337
+ }), this.renderRows({
338
+ table: table
339
+ }));
340
+ }
341
+ }]);
342
+ return TwoDimensionTable;
343
+ }(PureComponent);
344
+ export default TwoDimensionTable;