dtable-statistic 4.4.24 → 5.0.0-alpha.0

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 (208) hide show
  1. package/es/assets/css/dashboard.css +1 -0
  2. package/es/assets/css/dialog.css +35 -0
  3. package/es/components/dialog/chart-edit-dialog.js +93 -0
  4. package/es/components/dialog/enlarged-chart-dialog.js +8 -13
  5. package/es/components/dialog/statistic-record-dialog/index.js +26 -33
  6. package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
  7. package/es/constants/index.js +3 -499
  8. package/es/dashboard.js +9 -87
  9. package/es/desktop-dashboard.js +51 -32
  10. package/es/index.js +56 -1
  11. package/es/mobile-dashboard.js +8 -16
  12. package/es/model/conver-statItem.js +124 -0
  13. package/es/service/chart-service.js +8 -27
  14. package/es/service/dashboard-service.js +25 -29
  15. package/es/stat-list/chart-preview.js +19 -20
  16. package/es/stat-list/index.js +15 -21
  17. package/es/stat-view/index.js +47 -156
  18. package/es/tabs/tab.js +17 -14
  19. package/es/utils/common-utils.js +2 -352
  20. package/es/utils/export-table-utils.js +0 -69
  21. package/es/utils/index.js +0 -89
  22. package/package.json +5 -7
  23. package/es/assets/css/color-picker.css +0 -53
  24. package/es/assets/css/color-rules-popover.css +0 -144
  25. package/es/assets/css/slider.css +0 -77
  26. package/es/assets/css/statistic-chart.module.css +0 -11
  27. package/es/assets/css/statistic-custom-title.module.css +0 -3
  28. package/es/assets/css/statistic-custom.module.css +0 -4
  29. package/es/assets/css/statistic-numeric-column-item.module.css +0 -43
  30. package/es/assets/css/statistic-time-picker.module.css +0 -21
  31. package/es/calculator/base-calculator.js +0 -80
  32. package/es/calculator/basic-chart-calculator.js +0 -349
  33. package/es/calculator/combination-calculator.js +0 -246
  34. package/es/calculator/compare-bar-calculator.js +0 -197
  35. package/es/calculator/completeness-calculator.js +0 -215
  36. package/es/calculator/copy-value.js +0 -53
  37. package/es/calculator/dashboard-calculator.js +0 -70
  38. package/es/calculator/heat-map-calculator.js +0 -148
  39. package/es/calculator/horizontal-bar-calculator.js +0 -67
  40. package/es/calculator/index.js +0 -81
  41. package/es/calculator/map-calculator.js +0 -103
  42. package/es/calculator/mirror-calculator.js +0 -146
  43. package/es/calculator/number-card-calculator.js +0 -60
  44. package/es/calculator/pivot-table-calculator.js +0 -821
  45. package/es/calculator/scatter-calculator.js +0 -75
  46. package/es/calculator/thread-manager.js +0 -57
  47. package/es/calculator/trend-calculator.js +0 -113
  48. package/es/calculator/workers/basic-chart-calculator-worker.js +0 -495
  49. package/es/calculator/workers/calculator.worker.js +0 -44
  50. package/es/calculator/workers/card-calculator-worker.js +0 -40
  51. package/es/calculator/workers/combination-calculator-worker.js +0 -276
  52. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +0 -150
  53. package/es/calculator/workers/completeness-calculator-worker.js +0 -208
  54. package/es/calculator/workers/dashboard-calculator-worker.js +0 -68
  55. package/es/calculator/workers/mirror-calculator-worker.js +0 -152
  56. package/es/calculator/workers/pivot-table-calculator-worker.js +0 -718
  57. package/es/calculator/workers/scatter-calculator-worker.js +0 -80
  58. package/es/calculator/workers/trend-calculator-worker.js +0 -108
  59. package/es/calculator/world-map-calculator.js +0 -124
  60. package/es/components/common-add-tool.js +0 -28
  61. package/es/components/dialog/chart-addition-edit-dialog.js +0 -90
  62. package/es/components/dialog/chart-addition-widgets/chart-selector.js +0 -259
  63. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +0 -83
  64. package/es/components/dialog/statistic-types-dialog/index.css +0 -14
  65. package/es/components/dialog/statistic-types-dialog/index.js +0 -62
  66. package/es/components/dtable-popover.js +0 -97
  67. package/es/components/dtable-search-input.js +0 -135
  68. package/es/components/index.js +0 -55
  69. package/es/components/loading.js +0 -15
  70. package/es/components/modal-portal.js +0 -26
  71. package/es/components/popover/color-rules/color-rule.js +0 -183
  72. package/es/components/popover/color-rules/index.js +0 -87
  73. package/es/components/popover/color-rules/rule-filters/filter.js +0 -221
  74. package/es/components/popover/color-rules/rule-filters/index.css +0 -210
  75. package/es/components/popover/color-rules/rule-filters/index.js +0 -97
  76. package/es/components/popover/color-rules/rule-filters/number-input.js +0 -78
  77. package/es/components/popover/color-rules-popover.js +0 -217
  78. package/es/components/popover/color-selector-popover.js +0 -82
  79. package/es/components/seatable-radio/index.css +0 -51
  80. package/es/components/seatable-radio/index.js +0 -35
  81. package/es/constants/color-rules.js +0 -17
  82. package/es/constants/map.js +0 -13
  83. package/es/constants/model.js +0 -26
  84. package/es/constants/regions.js +0 -2111
  85. package/es/constants/zIndexes.js +0 -7
  86. package/es/custom-g2.js +0 -644
  87. package/es/model/bar-group.js +0 -58
  88. package/es/model/bar.js +0 -47
  89. package/es/model/base-model.js +0 -18
  90. package/es/model/basic-number-card.js +0 -25
  91. package/es/model/combination.js +0 -48
  92. package/es/model/compare-bar.js +0 -56
  93. package/es/model/completeness-group.js +0 -31
  94. package/es/model/completeness.js +0 -25
  95. package/es/model/custom-bar.js +0 -25
  96. package/es/model/dashboard.js +0 -20
  97. package/es/model/generic-model.js +0 -222
  98. package/es/model/heat-map.js +0 -33
  99. package/es/model/horizontal-bar-group.js +0 -55
  100. package/es/model/horizontal-bar.js +0 -47
  101. package/es/model/index.js +0 -187
  102. package/es/model/map.js +0 -38
  103. package/es/model/mirror.js +0 -33
  104. package/es/model/pie.js +0 -38
  105. package/es/model/ring.js +0 -40
  106. package/es/model/scatter.js +0 -22
  107. package/es/model/table.js +0 -32
  108. package/es/model/trend.js +0 -32
  109. package/es/model/world-map.js +0 -34
  110. package/es/service/map-json.js +0 -140
  111. package/es/stat-editor/chart-name-editor.js +0 -68
  112. package/es/stat-editor/index.js +0 -75
  113. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +0 -153
  114. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +0 -422
  115. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +0 -203
  116. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +0 -23
  117. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +0 -104
  118. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +0 -334
  119. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +0 -119
  120. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +0 -132
  121. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +0 -240
  122. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +0 -89
  123. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +0 -138
  124. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +0 -331
  125. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +0 -143
  126. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +0 -109
  127. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +0 -153
  128. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +0 -144
  129. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +0 -214
  130. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +0 -121
  131. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +0 -172
  132. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +0 -366
  133. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +0 -142
  134. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +0 -150
  135. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +0 -473
  136. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +0 -182
  137. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +0 -564
  138. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +0 -112
  139. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +0 -87
  140. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +0 -187
  141. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +0 -300
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +0 -113
  143. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +0 -289
  144. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +0 -58
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +0 -359
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +0 -48
  147. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +0 -121
  148. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +0 -143
  149. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +0 -269
  150. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +0 -104
  151. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +0 -366
  152. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +0 -55
  153. package/es/stat-editor/stat-settings/color-setting/color-picker.js +0 -130
  154. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +0 -374
  155. package/es/stat-editor/stat-settings/map/map-level.js +0 -72
  156. package/es/stat-editor/stat-settings/map/map-province-city.js +0 -151
  157. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +0 -108
  158. package/es/stat-editor/stat-settings/public-setting/base-settings.js +0 -154
  159. package/es/stat-editor/stat-settings/public-setting/calender.js +0 -125
  160. package/es/stat-editor/stat-settings/public-setting/column-settings.js +0 -24
  161. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +0 -62
  162. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +0 -61
  163. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +0 -35
  164. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +0 -60
  165. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +0 -123
  166. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +0 -33
  167. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +0 -29
  168. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +0 -82
  169. package/es/stat-view/area-chart.js +0 -551
  170. package/es/stat-view/bar-chart.js +0 -582
  171. package/es/stat-view/base-chart.js +0 -132
  172. package/es/stat-view/basic-number-card.js +0 -201
  173. package/es/stat-view/combination-chart.js +0 -546
  174. package/es/stat-view/compare-chart.js +0 -483
  175. package/es/stat-view/completeness-chart.js +0 -390
  176. package/es/stat-view/custom-bar.js +0 -418
  177. package/es/stat-view/dashboard-chart.js +0 -266
  178. package/es/stat-view/heat-map.js +0 -463
  179. package/es/stat-view/horizontal-bar-chart.js +0 -562
  180. package/es/stat-view/line-chart.js +0 -518
  181. package/es/stat-view/map.js +0 -448
  182. package/es/stat-view/mirror.js +0 -275
  183. package/es/stat-view/pie-chart.js +0 -290
  184. package/es/stat-view/pivot-table/index.js +0 -196
  185. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +0 -156
  186. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +0 -176
  187. package/es/stat-view/pivot-table/pivot-table-display-name.js +0 -215
  188. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +0 -132
  189. package/es/stat-view/pivot-table/two-dimension-table.js +0 -384
  190. package/es/stat-view/ring-chart.js +0 -392
  191. package/es/stat-view/scatter-chart.js +0 -306
  192. package/es/stat-view/treemap-chart.js +0 -253
  193. package/es/stat-view/trend-chart.js +0 -249
  194. package/es/stat-view/world-map.js +0 -431
  195. package/es/utils/basic-chart-utils.js +0 -29
  196. package/es/utils/cell-format.js +0 -115
  197. package/es/utils/collaborator.js +0 -50
  198. package/es/utils/color-utils.js +0 -134
  199. package/es/utils/column-utils.js +0 -110
  200. package/es/utils/column.js +0 -20
  201. package/es/utils/date-format.js +0 -71
  202. package/es/utils/map.js +0 -114
  203. package/es/utils/model.js +0 -19
  204. package/es/utils/row-utils.js +0 -134
  205. package/es/utils/search.js +0 -73
  206. package/es/utils/sql-utils.js +0 -359
  207. package/es/utils/stat-utils.js +0 -351
  208. package/es/utils/trend-utils.js +0 -135
package/es/tabs/tab.js CHANGED
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
11
- var _components = require("../components");
11
+ var _ModalPortal = _interopRequireDefault(require("dtable-ui-component/lib/ModalPortal"));
12
12
  var _utils = require("../utils");
13
13
  var _constants = require("../constants");
14
14
  var _statisticTabsModule = _interopRequireDefault(require("./statistic-tabs.module.css"));
@@ -23,19 +23,22 @@ class DashBoardTab extends _react.Component {
23
23
  }
24
24
  };
25
25
  this.onDropdownToggle = evt => {
26
+ var _this$btnViewDropdown;
26
27
  evt.nativeEvent.stopImmediatePropagation();
27
- const {
28
- top,
29
- left,
30
- height
31
- } = this.btnViewDropdown.parentNode.getBoundingClientRect();
32
- this.setState({
33
- isShowViewDropdown: !this.state.isShowViewDropdown,
34
- dropdownMenuPosition: {
35
- top: top + height - 3,
36
- left
37
- }
38
- });
28
+ if ((_this$btnViewDropdown = this.btnViewDropdown) !== null && _this$btnViewDropdown !== void 0 && _this$btnViewDropdown.parentNode) {
29
+ const {
30
+ top,
31
+ left,
32
+ height
33
+ } = this.btnViewDropdown.parentNode.getBoundingClientRect();
34
+ this.setState({
35
+ isShowViewDropdown: !this.state.isShowViewDropdown,
36
+ dropdownMenuPosition: {
37
+ top: top + height - 3,
38
+ left
39
+ }
40
+ });
41
+ }
39
42
  };
40
43
  this.onDragStart = event => {
41
44
  event.stopPropagation();
@@ -135,7 +138,7 @@ class DashBoardTab extends _react.Component {
135
138
  className: "".concat(_statisticTabsModule.default['btn-view-dropdown'])
136
139
  }, /*#__PURE__*/_react.default.createElement("i", {
137
140
  className: "".concat(_statisticTabsModule.default['icon'], " dtable-font dtable-icon-drop-down")
138
- }), isShowViewDropdown && /*#__PURE__*/_react.default.createElement(_components.ModalPortal, null, /*#__PURE__*/_react.default.createElement("div", {
141
+ }), isShowViewDropdown && /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement("div", {
139
142
  className: "".concat(theme === _constants.THEME_NAME_MAP.DARK ? 'statistic-tabs-dropdown-dark' : 'statistic-tabs-dropdown-light', " statistic-dropdown-menu dropdown-menu large show"),
140
143
  style: {
141
144
  ...dropdownMenuPosition,
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.arraysEqual = arraysEqual;
8
- exports.formatNumericValue = void 0;
9
- exports.formatPieChartData = formatPieChartData;
10
- exports.isShapeEqual = exports.isBoolean = exports.isArrayCellValue = exports.getSummaryResult = exports.getSummaryColumnMethod = exports.getLabelFontSize = exports.getImageUrl = exports.getCurrentTheme = exports.generatorUniqueId = void 0;
11
- exports.isStatItemEqual = isStatItemEqual;
12
- exports.shallowEqual = shallowEqual;
13
- exports.sortDataByGroupSum = exports.shouldCalculateStatItem = void 0;
6
+ exports.generatorUniqueId = void 0;
14
7
  var _dtableUtils = require("dtable-utils");
15
- var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
16
- var _constants = require("../constants");
17
- var _statUtils = _interopRequireDefault(require("./stat-utils"));
18
8
  const generatorUniqueId = list => {
19
9
  let uniqueId;
20
10
  let isUnique = false;
@@ -34,344 +24,4 @@ const generatorUniqueId = list => {
34
24
  }
35
25
  return uniqueId;
36
26
  };
37
- exports.generatorUniqueId = generatorUniqueId;
38
- const getImageUrl = imageName => {
39
- const {
40
- mediaUrl
41
- } = window.dtable;
42
- return "".concat(mediaUrl, "dtable-statistic/img/").concat(imageName);
43
- };
44
- exports.getImageUrl = getImageUrl;
45
- const isShapeEqual = (position1, position2) => {
46
- if (position1 && position2) {
47
- return position1.w === position2.w && position1.h === position2.h;
48
- }
49
- if (!position1 && !position2) return true;
50
- return false;
51
- };
52
- exports.isShapeEqual = isShapeEqual;
53
- function isStatItemEqual(prevStatItem, chart) {
54
- let statItemType = prevStatItem.type;
55
- if (statItemType !== chart.type) return false;
56
- return shallowEqual(prevStatItem, chart);
57
- }
58
- function shallowEqual(objA, objB) {
59
- if (objA === objB) {
60
- return true;
61
- }
62
- if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
63
- return false;
64
- }
65
- const keysA = Object.keys(objA);
66
- const keysB = Object.keys(objB);
67
- if (keysA.length !== keysB.length) {
68
- return false;
69
- }
70
- for (let i = 0; i < keysA.length; i++) {
71
- let key = keysA[i];
72
- let valueA = objA[key];
73
- let valueB = objB[key];
74
- if (key === 'layout') continue;
75
- // line | chart-bar | chart-bar-stack | chart-bar-group
76
- if (key === 'show_x_axis_label') continue;
77
- if (key === 'show_y_axis_label') continue;
78
- if (key === 'x_axis_label_position') continue;
79
- if (key === 'y_axis_label_position') continue;
80
-
81
- // horizontal bar | horizontal group bar
82
- if (key === 'show_vertical_axis_label') continue;
83
- if (key === 'show_horizontal_axis_label') continue;
84
- if (key === 'vertical_axis_label_position') continue;
85
- if (key === 'horizontal_axis_label_position') continue;
86
-
87
- // combination chart
88
- if (key === 'show_y_axis_left_label') continue;
89
- if (key === 'show_y_axis_right_label') continue;
90
- if (key === 'y_axis_left_label_position') continue;
91
- if (key === 'y_axis_right_label_position') continue;
92
- if (objA.type !== 'basic_number_card' && objA.type !== _constants.STAT_TYPE.DASHBOARD && key === 'name') continue;
93
- if (Object.prototype.hasOwnProperty.call(objB, key)) {
94
- if (Array.isArray(valueA) && Array.isArray(valueB)) {
95
- let isArrayEqual = arraysEqual(valueA, valueB);
96
- if (!isArrayEqual) return false;
97
- } else if (valueA !== valueB) {
98
- return false;
99
- }
100
- } else {
101
- return false;
102
- }
103
- }
104
- if (!isShapeEqual(objA.layout, objB.layout)) {
105
- return false;
106
- }
107
- return true;
108
- }
109
- const IGNORE_STAT_KEYS = ['layout', 'name', 'show_y_axis_label', 'show_x_axis_label', 'show_vertical_axis_label', 'show_horizontal_axis_label', 'vertical_axis_label_position', 'horizontal_axis_label_position', 'horizontal_axis_label_color', 'y_axis_label_color', 'data_color', 'display_data', 'show_y_axis_left_label', 'show_y_axis_right_label', 'x_axis_label_position', 'y_axis_label_position', 'y_axis_left_color', 'y_axis_right_color', 'y_axis_left_label_position', 'y_axis_right_label_position', 'minimum_slice_percent', 'bubble_color', 'map_type', 'legend_direction', 'legend_size', 'completed_color', 'uncompleted_color', 'display_percentage', 'label_font_size'];
110
- const shouldCalculateStatItem = (prevStatItem, chart) => {
111
- let statItemType = prevStatItem.type;
112
- if (statItemType !== chart.type) return true;
113
- if (prevStatItem === chart) {
114
- return false;
115
- }
116
- if (typeof prevStatItem !== 'object' || !prevStatItem || typeof chart !== 'object' || !chart) {
117
- return true;
118
- }
119
- const keysA = Object.keys(prevStatItem);
120
- const keysB = Object.keys(chart);
121
- if (keysA.length !== keysB.length) {
122
- return true;
123
- }
124
- for (let i = 0; i < keysA.length; i++) {
125
- let key = keysA[i];
126
- let valueA = prevStatItem[key];
127
- let valueB = chart[key];
128
- if (IGNORE_STAT_KEYS.includes(key)) continue;
129
- if (Object.prototype.hasOwnProperty.call(chart, key)) {
130
- if (Array.isArray(valueA) && Array.isArray(valueB)) {
131
- let isArrayEqual = arraysEqual(valueA, valueB);
132
- if (!isArrayEqual) return true;
133
- } else if (valueA !== valueB) {
134
- return true;
135
- }
136
- } else {
137
- return true;
138
- }
139
- }
140
- return false;
141
- };
142
- exports.shouldCalculateStatItem = shouldCalculateStatItem;
143
- function arraysEqual(arrayA, arrayB) {
144
- if (arrayA === null || arrayB === null) return false;
145
- if (arrayA.length !== arrayB.length) return false;
146
- for (let i = 0; i < arrayA.length; i++) {
147
- if (!shallowEqual(arrayA[i], arrayB[i])) return false;
148
- }
149
- return true;
150
- }
151
- const isArrayCellValue = column => {
152
- if (!column) return false;
153
- const {
154
- type,
155
- data
156
- } = column;
157
- return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY && _dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
158
- ;
159
- };
160
- exports.isArrayCellValue = isArrayCellValue;
161
- const getSummaryResult = function (results, summaryMethod) {
162
- let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
163
- const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableUtils.isNumber)(res)) : [];
164
- switch (summaryMethod) {
165
- case _constants.SUMMARY_METHOD_MAP.Max:
166
- {
167
- return getMax(numericResults);
168
- }
169
- case _constants.SUMMARY_METHOD_MAP.Min:
170
- {
171
- return getMin(numericResults);
172
- }
173
- case _constants.SUMMARY_METHOD_MAP.Sum:
174
- {
175
- return getSum(numericResults, precision);
176
- }
177
- case _constants.SUMMARY_METHOD_MAP.Mean:
178
- {
179
- return getMean(numericResults, precision);
180
- }
181
- case _constants.SUMMARY_METHOD_MAP.Distinct_values:
182
- {
183
- let count = 0;
184
- let existMap = {};
185
- Array.isArray(results) && results.forEach(resNum => {
186
- let num = resNum;
187
- if (!num) {
188
- if (num === 0) {
189
- num = '0';
190
- } else {
191
- num = !!num;
192
- }
193
- }
194
- if (!existMap[num]) {
195
- existMap[num] = true;
196
- count++;
197
- }
198
- });
199
- return count;
200
- }
201
- default:
202
- {
203
- return 0;
204
- }
205
- }
206
- };
207
- exports.getSummaryResult = getSummaryResult;
208
- const getMax = list => {
209
- if (list.length === 0) return 0;
210
- return Number.parseFloat(Math.max.apply(null, list));
211
- };
212
- const getMin = list => {
213
- if (list.length === 0) return 0;
214
- return Number.parseFloat(Math.min.apply(null, list).toFixed(8));
215
- };
216
- const getSum = function (list) {
217
- let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
218
- if (list.length === 0) return 0;
219
- const sum = list.reduce((a, b) => {
220
- return a + b;
221
- }, 0);
222
- return Number.parseFloat(Number(sum).toFixed(8));
223
- };
224
- const getMean = function (list) {
225
- let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
226
- if (list.length === 0) return 0;
227
- const sum = getSum(list);
228
- return Number.parseFloat((sum / list.length).toFixed(precision));
229
- };
230
- const getPieColor = (color_option, column, index, data, currentTheme) => {
231
- let {
232
- type: columnType,
233
- data: columnData
234
- } = column;
235
- const {
236
- colors
237
- } = currentTheme;
238
- if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT)) {
239
- if (columnData && columnData.options) {
240
- const selectedItem = columnData.options.find(item => item.name === data.name) || {};
241
- return selectedItem.color || '#dbdbdb';
242
- }
243
- } else {
244
- const sIndex = String(index);
245
- const colorIndex = sIndex.charAt(sIndex.length - 1);
246
- return colors[colorIndex];
247
- }
248
- };
249
- function formatPieChartData(data, statItem, table, currentTheme) {
250
- const {
251
- groupby_column_key,
252
- color_option,
253
- summary_column_key,
254
- summary_method: summaryMethod,
255
- summary_type
256
- } = statItem;
257
- const isAdvanced = summary_type === 'advanced';
258
- const column = (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
259
- let sum = data.reduce((total, currentValue) => {
260
- return total += currentValue.value;
261
- }, 0);
262
- const minimumSlicePercentage = typeof statItem.minimum_slice_percent === 'number' ? statItem.minimum_slice_percent : 1.5;
263
- const threshold = sum * (minimumSlicePercentage / 100 || 0);
264
- const filteredItems = [];
265
- const colorSet = [];
266
- const filteredData = [];
267
- let stepIndex = 0;
268
- data.forEach((item, index) => {
269
- const value = item.value;
270
- if (value >= threshold) {
271
- const colorIndex = index - stepIndex;
272
- item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
273
- const color = getPieColor(color_option, column, colorIndex, item, currentTheme);
274
- item.color = color;
275
- colorSet.push(color);
276
- filteredData.push(item);
277
- } else {
278
- stepIndex += 1;
279
- filteredItems.push(item);
280
- }
281
- });
282
- data = filteredData;
283
- if (filteredItems.length > 0) {
284
- const filteredSum = filteredItems.reduce((total, currentValue) => {
285
- return total += currentValue.value;
286
- }, 0);
287
- let formattedValueSum = filteredSum;
288
- if (isAdvanced) {
289
- const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
290
- formattedValueSum = _statUtils.default.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
291
- }
292
- let original_name_list = [];
293
- let name_list = [];
294
- let rows = [];
295
- filteredItems.forEach(item => {
296
- if (item.original_name) {
297
- original_name_list.push(item.original_name);
298
- }
299
- if (item.name) {
300
- name_list.push(item.name);
301
- }
302
- if (item.rows) {
303
- rows.push(...item.rows);
304
- }
305
- });
306
- data.push({
307
- rows,
308
- name_list,
309
- original_name_list,
310
- name: _reactIntlUniversal.default.get('Others'),
311
- value: filteredSum,
312
- formatted_value: formattedValueSum,
313
- color: '#dbdbdb',
314
- original_name: 'Others',
315
- percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%'
316
- });
317
- colorSet.push('#dbdbdb');
318
- }
319
- data.total = sum;
320
- data.colorSet = colorSet;
321
- return data;
322
- }
323
- const formatNumericValue = function (value) {
324
- let column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
325
- const data = column.data || {};
326
- let {
327
- precision = 8
328
- } = data;
329
- value = value || 0;
330
- return parseFloat(value.toFixed(precision));
331
- };
332
- exports.formatNumericValue = formatNumericValue;
333
- const getLabelFontSize = label_font_size => {
334
- return (0, _dtableUtils.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
335
- };
336
- exports.getLabelFontSize = getLabelFontSize;
337
- const getSummaryColumnMethod = function (method, summaryColumnName) {
338
- let useSingleQuote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
339
- if (method === 'Distinct_values') {
340
- return "COUNT(DISTINCT ".concat(summaryColumnName, ")");
341
- }
342
- return "".concat(method, "(").concat(useSingleQuote ? '`' : '').concat(summaryColumnName).concat(useSingleQuote ? '`' : '', ")");
343
- };
344
- exports.getSummaryColumnMethod = getSummaryColumnMethod;
345
- const getCurrentTheme = colorThemeName => {
346
- if (colorThemeName) {
347
- const currentColorTheme = _constants.CHART_STYLE_COLORS.find(item => item.name === colorThemeName);
348
- return currentColorTheme || _constants.CHART_STYLE_COLORS[0];
349
- }
350
- return _constants.CHART_STYLE_COLORS[0];
351
- };
352
-
353
- // for stacked bar, stacked horizontal bar
354
- exports.getCurrentTheme = getCurrentTheme;
355
- const sortDataByGroupSum = (data, sortType) => {
356
- const nameSumMap = [];
357
- data.forEach(item => {
358
- if (nameSumMap.filter(filteredItem => filteredItem.name === item.name).length === 0) {
359
- const items = data.filter(originItem => originItem.name === item.name);
360
- const valueSum = items.reduce((accumulator, currentItem) => accumulator + currentItem.value, 0);
361
- nameSumMap.push({
362
- name: item.name,
363
- items,
364
- valueSum
365
- });
366
- }
367
- });
368
-
369
- // sort group
370
- _statUtils.default.sortDataByKey(nameSumMap, 'valueSum', sortType);
371
- return nameSumMap.reduce((accumulator, currentItem) => accumulator.concat(currentItem.items), []);
372
- };
373
- exports.sortDataByGroupSum = sortDataByGroupSum;
374
- const isBoolean = val => {
375
- return typeof val === 'boolean';
376
- };
377
- exports.isBoolean = isBoolean;
27
+ exports.generatorUniqueId = generatorUniqueId;
@@ -9,8 +9,6 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
10
10
  var _dtableUtils = require("dtable-utils");
11
11
  var _cellValue = require("./cell-value");
12
- var _column = require("./column");
13
- var _collaborator = require("./collaborator");
14
12
  var _constants = require("../constants");
15
13
  var _pivotTable = require("./pivot-table");
16
14
  const isEmptyName = title => {
@@ -23,73 +21,6 @@ const isSummaryDateColumn = summaryColumn => {
23
21
  } = summaryColumn;
24
22
  return type !== _dtableUtils.CellType.LINK && (0, _dtableUtils.isDateColumn)(summaryColumn);
25
23
  };
26
-
27
- // eslint-disable-next-line
28
- const getTableValueDisplayName = (value, column) => {
29
- let {
30
- type,
31
- data
32
- } = column || {};
33
- let {
34
- collaborators
35
- } = window.app.state;
36
- switch (type) {
37
- case _dtableUtils.CellType.SINGLE_SELECT:
38
- case _dtableUtils.CellType.MULTIPLE_SELECT:
39
- {
40
- let options = (0, _column.getSelectColumnOptions)(column);
41
- let option = (0, _dtableUtils.getOption)(options, value) || {};
42
- return option.name;
43
- }
44
- case _dtableUtils.CellType.COLLABORATOR:
45
- {
46
- let collaborator = (0, _dtableUtils.getCollaborator)(collaborators, value) || {};
47
- return collaborator.name;
48
- }
49
- case _dtableUtils.CellType.CREATOR:
50
- case _dtableUtils.CellType.LAST_MODIFIER:
51
- {
52
- let collaborator = (0, _collaborator.getKnownCreatorByEmail)(collaborators, value) || {};
53
- return collaborator.name;
54
- }
55
- case _dtableUtils.CellType.NUMBER:
56
- {
57
- let valueNumber = parseFloat(value);
58
- let displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
59
- return displayValue;
60
- }
61
- case _dtableUtils.CellType.DATE:
62
- {
63
- let displayValue = value;
64
- if (value && value.split('-').length === 3) {
65
- let format = (0, _column.getDateColumnFormat)(column);
66
- let spaceIndex = format.indexOf(' ');
67
- if (spaceIndex > -1) {
68
- format = format.slice(0, spaceIndex);
69
- }
70
- displayValue = (0, _dayjs.default)(value).format(format);
71
- }
72
- return displayValue;
73
- }
74
- case _dtableUtils.CellType.FORMULA:
75
- case _dtableUtils.CellType.LINK_FORMULA:
76
- {
77
- let displayValue = value;
78
- let {
79
- result_type
80
- } = data || {};
81
- if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
82
- let valueNumber = parseFloat(value);
83
- displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
84
- }
85
- return displayValue;
86
- }
87
- default:
88
- {
89
- return value;
90
- }
91
- }
92
- };
93
24
  const getValidValueForColumn = (column, value) => {
94
25
  if (!column) return '';
95
26
  const {
package/es/utils/index.js CHANGED
@@ -3,94 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "generateDefaultUser", {
7
- enumerable: true,
8
- get: function () {
9
- return _collaborator.generateDefaultUser;
10
- }
11
- });
12
- Object.defineProperty(exports, "getClientCellValueDisplayString", {
13
- enumerable: true,
14
- get: function () {
15
- return _cellFormat.getClientCellValueDisplayString;
16
- }
17
- });
18
- Object.defineProperty(exports, "getClientFormulaDisplayString", {
19
- enumerable: true,
20
- get: function () {
21
- return _cellFormat.getClientFormulaDisplayString;
22
- }
23
- });
24
- Object.defineProperty(exports, "getDateColumnFormat", {
25
- enumerable: true,
26
- get: function () {
27
- return _column.getDateColumnFormat;
28
- }
29
- });
30
6
  exports.getEventClassName = void 0;
31
- Object.defineProperty(exports, "getKnownCreatorByEmail", {
32
- enumerable: true,
33
- get: function () {
34
- return _collaborator.getKnownCreatorByEmail;
35
- }
36
- });
37
- Object.defineProperty(exports, "getSelectColumnOptions", {
38
- enumerable: true,
39
- get: function () {
40
- return _column.getSelectColumnOptions;
41
- }
42
- });
43
- Object.defineProperty(exports, "getTodayDate", {
44
- enumerable: true,
45
- get: function () {
46
- return _dateFormat.getTodayDate;
47
- }
48
- });
49
7
  Object.defineProperty(exports, "hasOwnProperty", {
50
8
  enumerable: true,
51
9
  get: function () {
52
10
  return _object.hasOwnProperty;
53
11
  }
54
12
  });
55
- exports.hexToRgb = void 0;
56
- Object.defineProperty(exports, "isCellValueChanged", {
57
- enumerable: true,
58
- get: function () {
59
- return _cellValue.isCellValueChanged;
60
- }
61
- });
62
- Object.defineProperty(exports, "isEmptyObject", {
63
- enumerable: true,
64
- get: function () {
65
- return _object.isEmptyObject;
66
- }
67
- });
68
13
  exports.isMobile = exports.isFunction = void 0;
69
- Object.defineProperty(exports, "isSameObject", {
70
- enumerable: true,
71
- get: function () {
72
- return _object.isSameObject;
73
- }
74
- });
75
- Object.defineProperty(exports, "searchRows", {
76
- enumerable: true,
77
- get: function () {
78
- return _search.searchRows;
79
- }
80
- });
81
- Object.defineProperty(exports, "translateCalendar", {
82
- enumerable: true,
83
- get: function () {
84
- return _dateFormat.translateCalendar;
85
- }
86
- });
87
- var _cellFormat = require("./cell-format");
88
14
  var _object = require("./object");
89
- var _cellValue = require("./cell-value");
90
- var _collaborator = require("./collaborator");
91
- var _column = require("./column");
92
- var _dateFormat = require("./date-format");
93
- var _search = require("./search");
94
15
  const isFunction = functionToCheck => {
95
16
  const getType = {};
96
17
  return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
@@ -102,14 +23,4 @@ const getEventClassName = e => {
102
23
  return e.target.getAttribute('class') || '';
103
24
  };
104
25
  exports.getEventClassName = getEventClassName;
105
- const hexToRgb = hex => {
106
- hex = hex.replace('#', '');
107
- const bigint = parseInt(hex, 16);
108
- return {
109
- r: bigint >> 16 & 255,
110
- g: bigint >> 8 & 255,
111
- b: bigint & 255
112
- };
113
- };
114
- exports.hexToRgb = hexToRgb;
115
26
  const isMobile = exports.isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.4.24",
3
+ "version": "5.0.0-alpha.0",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
7
7
  "private": false,
8
8
  "dependencies": {
9
- "@antv/data-set": "0.11.8",
10
- "@antv/g2": "4.1.46",
11
- "@antv/util": "3.3.2",
9
+ "@antv/util": "^3.3.2",
12
10
  "@seafile/seafile-calendar": "0.0.24",
13
11
  "comlink": "^4.4.1",
14
12
  "dayjs": "1.10.7",
@@ -19,10 +17,10 @@
19
17
  "react-dom": "17.0.2",
20
18
  "react-grid-layout": "^1.2.5",
21
19
  "react-intl-universal": "^2.4.8",
22
- "reactstrap": "8.9.0"
20
+ "reactstrap": "8.9.0",
21
+ "sea-chart": "^0.0.47-alpha.2"
23
22
  },
24
23
  "peerDependencies": {
25
- "@antv/scale": "0.3.14",
26
24
  "dtable-ui-component": "~4.4.*",
27
25
  "dtable-utils": "~4.4.*"
28
26
  },
@@ -56,7 +54,7 @@
56
54
  "dotenv": "^10.0.0",
57
55
  "dotenv-expand": "^5.1.0",
58
56
  "dtable-store": "4.3.6",
59
- "dtable-ui-component": "4.4.34",
57
+ "dtable-ui-component": "~4.4.34",
60
58
  "dtable-utils": "4.4.0",
61
59
  "eslint": "^8.3.0",
62
60
  "eslint-config-react-app": "^7.0.1",