dtable-statistic 5.0.0 → 5.0.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 (201) 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 +27 -35
  6. package/es/components/dialog/table-select-dialog.js +3 -3
  7. package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
  8. package/es/constants/index.js +3 -499
  9. package/es/dashboard.js +9 -87
  10. package/es/desktop-dashboard.js +51 -32
  11. package/es/index.js +56 -1
  12. package/es/mobile-dashboard.js +8 -16
  13. package/es/model/conver-statItem.js +124 -0
  14. package/es/service/chart-service.js +8 -27
  15. package/es/service/dashboard-service.js +25 -29
  16. package/es/stat-list/chart-preview.js +19 -20
  17. package/es/stat-list/index.js +17 -23
  18. package/es/stat-view/index.js +47 -156
  19. package/es/tabs/tab.js +18 -15
  20. package/es/utils/common-utils.js +2 -352
  21. package/es/utils/export-table-utils.js +0 -69
  22. package/es/utils/index.js +12 -89
  23. package/package.json +5 -8
  24. package/es/assets/css/color-picker.css +0 -53
  25. package/es/assets/css/color-rules-popover.css +0 -144
  26. package/es/assets/css/slider.css +0 -77
  27. package/es/assets/css/statistic-chart.module.css +0 -11
  28. package/es/assets/css/statistic-custom-title.module.css +0 -3
  29. package/es/assets/css/statistic-custom.module.css +0 -4
  30. package/es/assets/css/statistic-numeric-column-item.module.css +0 -43
  31. package/es/assets/css/statistic-time-picker.module.css +0 -21
  32. package/es/calculator/base-calculator.js +0 -80
  33. package/es/calculator/basic-chart-calculator.js +0 -349
  34. package/es/calculator/combination-calculator.js +0 -246
  35. package/es/calculator/compare-bar-calculator.js +0 -197
  36. package/es/calculator/completeness-calculator.js +0 -215
  37. package/es/calculator/copy-value.js +0 -53
  38. package/es/calculator/dashboard-calculator.js +0 -70
  39. package/es/calculator/heat-map-calculator.js +0 -148
  40. package/es/calculator/horizontal-bar-calculator.js +0 -67
  41. package/es/calculator/index.js +0 -81
  42. package/es/calculator/map-calculator.js +0 -103
  43. package/es/calculator/mirror-calculator.js +0 -146
  44. package/es/calculator/number-card-calculator.js +0 -60
  45. package/es/calculator/pivot-table-calculator.js +0 -821
  46. package/es/calculator/scatter-calculator.js +0 -75
  47. package/es/calculator/thread-manager.js +0 -57
  48. package/es/calculator/trend-calculator.js +0 -113
  49. package/es/calculator/workers/basic-chart-calculator-worker.js +0 -495
  50. package/es/calculator/workers/calculator.worker.js +0 -44
  51. package/es/calculator/workers/card-calculator-worker.js +0 -40
  52. package/es/calculator/workers/combination-calculator-worker.js +0 -276
  53. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +0 -150
  54. package/es/calculator/workers/completeness-calculator-worker.js +0 -208
  55. package/es/calculator/workers/dashboard-calculator-worker.js +0 -68
  56. package/es/calculator/workers/mirror-calculator-worker.js +0 -152
  57. package/es/calculator/workers/pivot-table-calculator-worker.js +0 -718
  58. package/es/calculator/workers/scatter-calculator-worker.js +0 -80
  59. package/es/calculator/workers/trend-calculator-worker.js +0 -108
  60. package/es/calculator/world-map-calculator.js +0 -124
  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/popover/color-rules/color-rule.js +0 -183
  67. package/es/components/popover/color-rules/index.js +0 -87
  68. package/es/components/popover/color-rules/rule-filters/filter.js +0 -221
  69. package/es/components/popover/color-rules/rule-filters/index.css +0 -210
  70. package/es/components/popover/color-rules/rule-filters/index.js +0 -97
  71. package/es/components/popover/color-rules/rule-filters/number-input.js +0 -78
  72. package/es/components/popover/color-rules-popover.js +0 -218
  73. package/es/components/popover/color-selector-popover.js +0 -83
  74. package/es/constants/color-rules.js +0 -17
  75. package/es/constants/map.js +0 -13
  76. package/es/constants/model.js +0 -26
  77. package/es/constants/regions.js +0 -2111
  78. package/es/constants/zIndexes.js +0 -7
  79. package/es/custom-g2.js +0 -644
  80. package/es/model/bar-group.js +0 -58
  81. package/es/model/bar.js +0 -47
  82. package/es/model/base-model.js +0 -18
  83. package/es/model/basic-number-card.js +0 -25
  84. package/es/model/combination.js +0 -48
  85. package/es/model/compare-bar.js +0 -56
  86. package/es/model/completeness-group.js +0 -31
  87. package/es/model/completeness.js +0 -25
  88. package/es/model/custom-bar.js +0 -25
  89. package/es/model/dashboard.js +0 -20
  90. package/es/model/generic-model.js +0 -222
  91. package/es/model/heat-map.js +0 -33
  92. package/es/model/horizontal-bar-group.js +0 -55
  93. package/es/model/horizontal-bar.js +0 -47
  94. package/es/model/index.js +0 -187
  95. package/es/model/map.js +0 -38
  96. package/es/model/mirror.js +0 -33
  97. package/es/model/pie.js +0 -38
  98. package/es/model/ring.js +0 -40
  99. package/es/model/scatter.js +0 -22
  100. package/es/model/table.js +0 -32
  101. package/es/model/trend.js +0 -32
  102. package/es/model/world-map.js +0 -34
  103. package/es/service/map-json.js +0 -140
  104. package/es/stat-editor/chart-name-editor.js +0 -68
  105. package/es/stat-editor/index.js +0 -75
  106. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +0 -153
  107. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +0 -422
  108. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +0 -203
  109. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +0 -23
  110. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +0 -104
  111. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +0 -334
  112. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +0 -119
  113. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +0 -132
  114. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +0 -240
  115. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +0 -89
  116. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +0 -138
  117. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +0 -331
  118. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +0 -143
  119. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +0 -109
  120. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +0 -153
  121. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +0 -144
  122. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +0 -214
  123. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +0 -121
  124. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +0 -172
  125. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +0 -366
  126. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +0 -142
  127. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +0 -150
  128. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +0 -473
  129. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +0 -182
  130. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +0 -564
  131. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +0 -112
  132. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +0 -87
  133. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +0 -187
  134. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +0 -300
  135. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +0 -113
  136. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +0 -289
  137. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +0 -58
  138. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +0 -359
  139. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +0 -48
  140. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +0 -121
  141. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +0 -143
  142. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +0 -269
  143. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +0 -104
  144. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +0 -366
  145. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +0 -55
  146. package/es/stat-editor/stat-settings/color-setting/color-picker.js +0 -130
  147. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +0 -374
  148. package/es/stat-editor/stat-settings/map/map-level.js +0 -72
  149. package/es/stat-editor/stat-settings/map/map-province-city.js +0 -151
  150. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +0 -108
  151. package/es/stat-editor/stat-settings/public-setting/base-settings.js +0 -154
  152. package/es/stat-editor/stat-settings/public-setting/calender.js +0 -125
  153. package/es/stat-editor/stat-settings/public-setting/column-settings.js +0 -24
  154. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +0 -62
  155. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +0 -61
  156. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +0 -35
  157. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +0 -60
  158. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +0 -123
  159. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +0 -33
  160. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +0 -29
  161. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +0 -82
  162. package/es/stat-view/area-chart.js +0 -551
  163. package/es/stat-view/bar-chart.js +0 -582
  164. package/es/stat-view/base-chart.js +0 -132
  165. package/es/stat-view/basic-number-card.js +0 -201
  166. package/es/stat-view/combination-chart.js +0 -546
  167. package/es/stat-view/compare-chart.js +0 -483
  168. package/es/stat-view/completeness-chart.js +0 -390
  169. package/es/stat-view/custom-bar.js +0 -418
  170. package/es/stat-view/dashboard-chart.js +0 -266
  171. package/es/stat-view/heat-map.js +0 -463
  172. package/es/stat-view/horizontal-bar-chart.js +0 -562
  173. package/es/stat-view/line-chart.js +0 -518
  174. package/es/stat-view/map.js +0 -448
  175. package/es/stat-view/mirror.js +0 -275
  176. package/es/stat-view/pie-chart.js +0 -290
  177. package/es/stat-view/pivot-table/index.js +0 -196
  178. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +0 -156
  179. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +0 -176
  180. package/es/stat-view/pivot-table/pivot-table-display-name.js +0 -215
  181. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +0 -132
  182. package/es/stat-view/pivot-table/two-dimension-table.js +0 -384
  183. package/es/stat-view/ring-chart.js +0 -392
  184. package/es/stat-view/scatter-chart.js +0 -306
  185. package/es/stat-view/treemap-chart.js +0 -253
  186. package/es/stat-view/trend-chart.js +0 -249
  187. package/es/stat-view/world-map.js +0 -431
  188. package/es/utils/basic-chart-utils.js +0 -29
  189. package/es/utils/cell-format.js +0 -115
  190. package/es/utils/collaborator.js +0 -50
  191. package/es/utils/color-utils.js +0 -134
  192. package/es/utils/column-utils.js +0 -110
  193. package/es/utils/column.js +0 -20
  194. package/es/utils/date-format.js +0 -71
  195. package/es/utils/map.js +0 -114
  196. package/es/utils/model.js +0 -19
  197. package/es/utils/row-utils.js +0 -134
  198. package/es/utils/search.js +0 -73
  199. package/es/utils/sql-utils.js +0 -359
  200. package/es/utils/stat-utils.js +0 -351
  201. package/es/utils/trend-utils.js +0 -135
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _basicChartCalculator = _interopRequireDefault(require("./basic-chart-calculator"));
9
- var _constants = require("../constants");
10
- class HorizontalBarCalculator {
11
- constructor(props) {
12
- this.basicChartCalculator = new _basicChartCalculator.default(props);
13
- }
14
- isValidChart(chart) {
15
- const convertedChart = this.convertChart(chart);
16
- return this.basicChartCalculator.isValidChart(convertedChart);
17
- }
18
- async calculate(chart) {
19
- const convertedChart = this.convertChart(chart);
20
- return await this.basicChartCalculator.calculate(convertedChart);
21
- }
22
- convertChart(chart) {
23
- const {
24
- _id,
25
- table_id,
26
- view_id,
27
- vertical_axis_column_key,
28
- vertical_axis_date_granularity,
29
- vertical_axis_geolocation_granularity,
30
- vertical_axis_include_empty,
31
- horizontal_axis_summary_type,
32
- horizontal_axis_column_key,
33
- horizontal_axis_summary_method,
34
- column_groupby_column_key,
35
- column_groupby_date_granularity,
36
- column_groupby_geolocation_granularity,
37
- column_groupby_multiple_numeric_column,
38
- column_groupby_numeric_columns
39
- } = chart;
40
- let sortType = chart.sort_type;
41
- if (sortType === _constants.DATA_SORT_TYPE.ASCENDING) {
42
- sortType = _constants.DATA_SORT_TYPE.DESCENDING;
43
- } else if (sortType === _constants.DATA_SORT_TYPE.DESCENDING) {
44
- sortType = _constants.DATA_SORT_TYPE.ASCENDING;
45
- }
46
- return {
47
- type: 'bar',
48
- _id,
49
- table_id,
50
- view_id,
51
- y_axis_column_key: horizontal_axis_column_key,
52
- x_axis_date_granularity: vertical_axis_date_granularity,
53
- x_axis_geolocation_granularity: vertical_axis_geolocation_granularity,
54
- x_axis_include_empty: vertical_axis_include_empty,
55
- y_axis_summary_type: horizontal_axis_summary_type,
56
- x_axis_column_key: vertical_axis_column_key,
57
- y_axis_summary_method: horizontal_axis_summary_method,
58
- column_groupby_column_key,
59
- column_groupby_date_granularity,
60
- column_groupby_geolocation_granularity,
61
- column_groupby_multiple_numeric_column,
62
- column_groupby_numeric_columns,
63
- sort_type: sortType
64
- };
65
- }
66
- }
67
- var _default = exports.default = HorizontalBarCalculator;
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _pivotTableCalculator = _interopRequireDefault(require("./pivot-table-calculator"));
9
- var _basicChartCalculator = _interopRequireDefault(require("./basic-chart-calculator"));
10
- var _compareBarCalculator = _interopRequireDefault(require("./compare-bar-calculator"));
11
- var _horizontalBarCalculator = _interopRequireDefault(require("./horizontal-bar-calculator"));
12
- var _completenessCalculator = _interopRequireDefault(require("./completeness-calculator"));
13
- var _scatterCalculator = _interopRequireDefault(require("./scatter-calculator"));
14
- var _combinationCalculator = _interopRequireDefault(require("./combination-calculator"));
15
- var _mapCalculator = _interopRequireDefault(require("./map-calculator"));
16
- var _worldMapCalculator = _interopRequireDefault(require("./world-map-calculator"));
17
- var _heatMapCalculator = _interopRequireDefault(require("./heat-map-calculator"));
18
- var _mirrorCalculator = _interopRequireDefault(require("./mirror-calculator"));
19
- var _numberCardCalculator = _interopRequireDefault(require("./number-card-calculator"));
20
- var _trendCalculator = _interopRequireDefault(require("./trend-calculator"));
21
- var _dashboardCalculator = _interopRequireDefault(require("./dashboard-calculator"));
22
- var _constants = require("../constants");
23
- const BASIC_CHART = 'basic_chart';
24
- class ChartCalculator {
25
- constructor(_ref) {
26
- let {
27
- username,
28
- userId,
29
- userDepartmentIdsMap,
30
- value,
31
- statisticThreadManager
32
- } = _ref;
33
- const configs = {
34
- username,
35
- userId,
36
- userDepartmentIdsMap,
37
- value,
38
- statisticThreadManager
39
- };
40
- this.chartCalculationMap = {
41
- [_constants.STAT_TYPE.PIVOT_TABLE]: new _pivotTableCalculator.default(configs),
42
- [BASIC_CHART]: new _basicChartCalculator.default(configs),
43
- [_constants.STAT_TYPE.COMPARE_BAR]: new _compareBarCalculator.default(configs),
44
- [_constants.STAT_TYPE.HORIZONTAL_BAR]: new _horizontalBarCalculator.default(configs),
45
- [_constants.STAT_TYPE.HORIZONTAL_GROUP_BAR]: new _horizontalBarCalculator.default(configs),
46
- [_constants.STAT_TYPE.STACKED_HORIZONTAL_BAR]: new _horizontalBarCalculator.default(configs),
47
- [_constants.STAT_TYPE.COMPLETENESS_CHART]: new _completenessCalculator.default(configs),
48
- [_constants.STAT_TYPE.GROUP_COMPLETENESS_CHART]: new _completenessCalculator.default(configs),
49
- [_constants.STAT_TYPE.SCATTER]: new _scatterCalculator.default(configs),
50
- [_constants.STAT_TYPE.COMBINATION_CHART]: new _combinationCalculator.default(configs),
51
- [_constants.STAT_TYPE.MAP]: new _mapCalculator.default(configs),
52
- [_constants.STAT_TYPE.MAP_BUBBLE]: new _mapCalculator.default(configs),
53
- [_constants.STAT_TYPE.WORLD_MAP]: new _worldMapCalculator.default(configs),
54
- [_constants.STAT_TYPE.WORLD_MAP_BUBBLE]: new _worldMapCalculator.default(configs),
55
- [_constants.STAT_TYPE.HEAT_MAP]: new _heatMapCalculator.default(configs),
56
- [_constants.STAT_TYPE.MIRROR]: new _mirrorCalculator.default(configs),
57
- [_constants.STAT_TYPE.BASIC_NUMBER_CARD]: new _numberCardCalculator.default(configs),
58
- [_constants.STAT_TYPE.TREND_CHART]: new _trendCalculator.default(configs),
59
- [_constants.STAT_TYPE.DASHBOARD]: new _dashboardCalculator.default(configs)
60
- };
61
- }
62
- isValidChart(chart) {
63
- if (!chart) {
64
- return false;
65
- }
66
- const chartCalculation = this.chartCalculationMap[chart.type];
67
- if (!chartCalculation) {
68
- return this.chartCalculationMap[BASIC_CHART].isValidChart(chart);
69
- }
70
- return chartCalculation ? chartCalculation.isValidChart(chart) : false;
71
- }
72
- async calculate(chart) {
73
- if (!chart) return null;
74
- const chartCalculation = this.chartCalculationMap[chart.type];
75
- if (!chartCalculation) {
76
- return this.chartCalculationMap[BASIC_CHART].calculate(chart);
77
- }
78
- return chartCalculation.calculate(chart);
79
- }
80
- }
81
- var _default = exports.default = ChartCalculator;
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dtableUtils = require("dtable-utils");
9
- var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
10
- var _commonUtils = require("../utils/common-utils");
11
- var _sqlUtils = require("../utils/sql-utils");
12
- var _constants = require("../constants");
13
- var _map = require("../utils/map");
14
- var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
15
- class MapCalculator extends _baseCalculator.default {
16
- isValidChart(chart) {
17
- if (!this.validateBaseConfigs(chart)) {
18
- return false;
19
- }
20
- const {
21
- table_id,
22
- geo_column,
23
- summary_column
24
- } = chart;
25
- const table = this.getTableById(table_id);
26
- const selectedColumn = geo_column && (0, _dtableUtils.getTableColumnByKey)(table, geo_column);
27
- if (geo_column && (!selectedColumn || selectedColumn.type !== _dtableUtils.CellType.GEOLOCATION)) {
28
- return false;
29
- }
30
- if (summary_column && !(0, _dtableUtils.getTableColumnByKey)(table, summary_column)) {
31
- return false;
32
- }
33
- return true;
34
- }
35
- async calculate(chart) {
36
- if (!this.isValidChart(chart)) return [];
37
- if (this.isCalcByQueryDB(chart)) {
38
- return await this.queryDb(chart);
39
- }
40
- return await this.calculateWithWorker(chart);
41
- }
42
- async queryDb(chart) {
43
- const {
44
- table_id,
45
- view_id,
46
- geo_column,
47
- summary_type,
48
- summary_method,
49
- summary_column
50
- } = chart;
51
- const selectedTable = this.getTableById(table_id);
52
- const selectedView = this.getViewById(view_id, selectedTable);
53
- const column = (0, _dtableUtils.getTableColumnByKey)(selectedTable, geo_column);
54
- if (!column) return [];
55
- const columnName = column.name;
56
- const isAdvanced = summary_type === 'advanced';
57
- const geoGranularity = (0, _map.fixMapGeoGranularity)(chart);
58
- const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
59
- const sqlCondition = this.filter2SqlCondition(selectedTable, selectedView);
60
- const groupName = (0, _sqlUtils.getSqlGroup)(geoGranularity, column);
61
- let sqlString = '';
62
- let summaryColumn;
63
- let summaryColumnName = '';
64
- if (isAdvanced) {
65
- summaryColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, summary_column);
66
- if (!summaryColumn) {
67
- return [];
68
- }
69
- summaryColumnName = summaryColumn.name;
70
- const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
71
- sqlString = "select ".concat(groupName, ", ").concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, " limit 5000");
72
- } else {
73
- sqlString = "select ".concat(groupName, ", ").concat(method, "(`").concat(columnName, "`) from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, " limit 5000");
74
- }
75
- const result = await this.sqlQuery(sqlString);
76
- if (result.status === 200 && result.data.success) {
77
- const data = result.data;
78
- if (!data.results) return [];
79
- const newResult = [];
80
- const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
81
- const valueKey = isAdvanced ? "".concat(summaryColumnMethod) : "".concat(method, "(").concat(columnName, ")");
82
- data.results.forEach(item => {
83
- const currentValue = item[groupName];
84
- let value = item[valueKey];
85
- let formatted_value = value;
86
- if (isAdvanced) {
87
- value = (0, _commonUtils.formatNumericValue)(value, summaryColumn);
88
- formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, method);
89
- }
90
- if (currentValue) {
91
- newResult.push({
92
- name: currentValue,
93
- value,
94
- formatted_value
95
- });
96
- }
97
- });
98
- return newResult;
99
- }
100
- return [];
101
- }
102
- }
103
- var _default = exports.default = MapCalculator;
@@ -1,146 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dtableUtils = require("dtable-utils");
9
- var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
10
- var _commonUtils = require("../utils/common-utils");
11
- var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
12
- var _constants = require("../constants");
13
- class MirrorCalculator extends _baseCalculator.default {
14
- isValidChart(chart) {
15
- if (!this.validateBaseConfigs(chart)) {
16
- return false;
17
- }
18
- const {
19
- table_id,
20
- column,
21
- summary_column,
22
- group_column
23
- } = chart;
24
- const table = this.getTableById(table_id);
25
- if (!(0, _dtableUtils.getTableColumnByKey)(table, column)) {
26
- return false;
27
- }
28
- if (summary_column && !(0, _dtableUtils.getTableColumnByKey)(table, summary_column)) {
29
- return false;
30
- }
31
- const selectedGroupColumn = (0, _dtableUtils.getTableColumnByKey)(table, group_column);
32
- if (!selectedGroupColumn) return false;
33
- const data = selectedGroupColumn.data || {};
34
- const options = data.options || [];
35
- if (options.length < 2) return false;
36
- return true;
37
- }
38
- async calculate(chart) {
39
- if (!this.isValidChart(chart)) return [];
40
- if (this.isCalcByQueryDB(chart)) {
41
- return await this.queryDb(chart);
42
- }
43
- return await this.calculateWithWorker(chart);
44
- }
45
- async queryDb(chart) {
46
- const {
47
- column,
48
- table_id,
49
- view_id,
50
- summary_type,
51
- summary_method,
52
- summary_column,
53
- group_column
54
- } = chart;
55
- const selectedTable = this.getTableById(table_id);
56
- const selectedView = this.getViewById(view_id, selectedTable);
57
- let sqlString = '';
58
- const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column);
59
- const columnName = selectedColumn.name;
60
- const selectedGroupColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, group_column);
61
- const groupColumnName = selectedGroupColumn.name;
62
- const isAdvanced = summary_type === 'advanced';
63
- const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
64
- const sqlCondition = this.filter2SqlCondition(selectedTable, selectedView);
65
- let summaryColumnName = '',
66
- summaryColumn;
67
- if (isAdvanced) {
68
- summaryColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, summary_column);
69
- if (!summaryColumn) {
70
- return [];
71
- }
72
- summaryColumnName = summaryColumn.name;
73
- const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
74
- sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
75
- } else {
76
- sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(method, "(`").concat(columnName, "`) from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
77
- }
78
- const result = await this.sqlQuery(sqlString);
79
- if (result.status === 200 && result.data.success) {
80
- const data = result.data;
81
- if (!data.results) return [];
82
- const newResult = [];
83
- const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
84
- const valueKey = isAdvanced ? "".concat(summaryColumnMethod) : "".concat(method, "(").concat(columnName, ")");
85
- const groupData = this.getGroupData(data.results, selectedGroupColumn);
86
- if (groupData.length > 0) {
87
- const groupData0 = groupData[0] || {};
88
- const groupData1 = groupData[1] || {};
89
- data.results.forEach(item => {
90
- const label = _statUtils.default.getGroupLabel(item[column], item, selectedColumn, '', '', this.value);
91
- const groupValue = item[group_column];
92
- const equal2GroupData0 = groupData0.id === groupValue;
93
- const equal2GroupData1 = groupData1.id === groupValue;
94
- if (equal2GroupData0 || equal2GroupData1) {
95
- let value = item[valueKey];
96
- let formattedValue = value;
97
- if (isAdvanced) {
98
- value = (0, _commonUtils.formatNumericValue)(value, summaryColumn);
99
- formattedValue = _statUtils.default.getFormattedValue(value, summaryColumn, summary_method);
100
- }
101
- newResult.push({
102
- name: label,
103
- original_name: item[column],
104
- value: equal2GroupData0 ? value : 0,
105
- formatted_value: equal2GroupData0 ? formattedValue : 0,
106
- group_name: groupData[0].name,
107
- color: groupData[0].color
108
- }, {
109
- name: label,
110
- original_name: item[column],
111
- value: equal2GroupData1 ? value : 0,
112
- formatted_value: equal2GroupData1 ? formattedValue : 0,
113
- group_name: groupData[1].name,
114
- color: groupData[1].color
115
- });
116
- }
117
- });
118
- }
119
- return {
120
- data: newResult,
121
- colorSet: [groupData[0] && groupData[0].color, groupData[1] && groupData[1].color]
122
- };
123
- }
124
- return [];
125
- }
126
- getGroupData(result, groupColumn) {
127
- const {
128
- options = {}
129
- } = groupColumn.data || {};
130
- let groupCount = 0;
131
- let groupList = [];
132
- let cache = {};
133
- for (let i = 0; i < result.length; i++) {
134
- const groupValue = result[i][groupColumn.key];
135
- const item = options.find(optionItem => optionItem.id === groupValue);
136
- if (!cache[groupValue] && groupValue) {
137
- groupList.push(item);
138
- cache[groupValue] = true;
139
- groupCount++;
140
- }
141
- if (groupCount === 2) break;
142
- }
143
- return groupList;
144
- }
145
- }
146
- var _default = exports.default = MirrorCalculator;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dtableUtils = require("dtable-utils");
9
- var _constants = require("../constants");
10
- var _commonUtils = require("../utils/common-utils");
11
- var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
12
- class NumberCardCalculator extends _baseCalculator.default {
13
- isValidChart(chart) {
14
- if (!this.validateBaseConfigs(chart)) {
15
- return false;
16
- }
17
- const {
18
- table_id,
19
- numeric_column
20
- } = chart;
21
- const table = this.getTableById(table_id);
22
- if (!(0, _dtableUtils.getTableColumnByKey)(table, numeric_column)) {
23
- return false;
24
- }
25
- return true;
26
- }
27
- async calculate(chart) {
28
- if (!this.isValidChart(chart)) return 0;
29
- if (this.isCalcByQueryDB(chart)) {
30
- return await this.queryDb(chart);
31
- }
32
- return await this.calculateWithWorker(chart);
33
- }
34
- async queryDb(chart) {
35
- const {
36
- table_id,
37
- view_id,
38
- numeric_column,
39
- summary_method
40
- } = chart;
41
- const selectedTable = this.getTableById(table_id);
42
- const selectedView = this.getViewById(view_id, selectedTable);
43
- const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, numeric_column);
44
- const sqlCondition = this.filter2SqlCondition(selectedTable, selectedView);
45
- const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summary_method], selectedColumn.name);
46
- const sqlString = "select ".concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " limit 5000");
47
- const result = await this.sqlQuery(sqlString);
48
- if (result.status === 200 && result.data.success) {
49
- const data = result.data.results;
50
- if (!data) return 0;
51
- if (data.length > 0) {
52
- const summaryResult = data[0];
53
- const key = Object.keys(summaryResult)[0];
54
- return summaryResult[key];
55
- }
56
- }
57
- return 0;
58
- }
59
- }
60
- var _default = exports.default = NumberCardCalculator;