dtable-statistic 4.4.23 → 4.4.24-alpha.1

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 (196) hide show
  1. package/es/assets/css/dashboard.css +1 -0
  2. package/es/assets/css/dialog.css +30 -0
  3. package/es/components/dialog/chart-edit-dialog.js +92 -0
  4. package/es/components/dialog/enlarged-chart-dialog.js +8 -13
  5. package/es/components/dialog/statistic-record-dialog/index.js +22 -30
  6. package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
  7. package/es/components/index.js +1 -15
  8. package/es/constants/index.js +1 -2
  9. package/es/dashboard.js +5 -31
  10. package/es/desktop-dashboard.js +51 -32
  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 -15
  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 +13 -19
  17. package/es/stat-view/index.js +46 -156
  18. package/es/utils/common-utils.js +2 -352
  19. package/es/utils/export-table-utils.js +0 -69
  20. package/es/utils/index.js +0 -89
  21. package/package.json +5 -7
  22. package/es/assets/css/color-picker.css +0 -53
  23. package/es/assets/css/color-rules-popover.css +0 -144
  24. package/es/assets/css/slider.css +0 -77
  25. package/es/assets/css/statistic-chart.module.css +0 -11
  26. package/es/assets/css/statistic-custom-title.module.css +0 -3
  27. package/es/assets/css/statistic-custom.module.css +0 -4
  28. package/es/assets/css/statistic-numeric-column-item.module.css +0 -43
  29. package/es/assets/css/statistic-time-picker.module.css +0 -21
  30. package/es/calculator/base-calculator.js +0 -80
  31. package/es/calculator/basic-chart-calculator.js +0 -349
  32. package/es/calculator/combination-calculator.js +0 -246
  33. package/es/calculator/compare-bar-calculator.js +0 -197
  34. package/es/calculator/completeness-calculator.js +0 -215
  35. package/es/calculator/copy-value.js +0 -53
  36. package/es/calculator/dashboard-calculator.js +0 -70
  37. package/es/calculator/heat-map-calculator.js +0 -148
  38. package/es/calculator/horizontal-bar-calculator.js +0 -67
  39. package/es/calculator/index.js +0 -81
  40. package/es/calculator/map-calculator.js +0 -103
  41. package/es/calculator/mirror-calculator.js +0 -146
  42. package/es/calculator/number-card-calculator.js +0 -60
  43. package/es/calculator/pivot-table-calculator.js +0 -821
  44. package/es/calculator/scatter-calculator.js +0 -75
  45. package/es/calculator/thread-manager.js +0 -57
  46. package/es/calculator/trend-calculator.js +0 -113
  47. package/es/calculator/workers/basic-chart-calculator-worker.js +0 -495
  48. package/es/calculator/workers/calculator.worker.js +0 -44
  49. package/es/calculator/workers/card-calculator-worker.js +0 -40
  50. package/es/calculator/workers/combination-calculator-worker.js +0 -276
  51. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +0 -150
  52. package/es/calculator/workers/completeness-calculator-worker.js +0 -208
  53. package/es/calculator/workers/dashboard-calculator-worker.js +0 -68
  54. package/es/calculator/workers/mirror-calculator-worker.js +0 -152
  55. package/es/calculator/workers/pivot-table-calculator-worker.js +0 -718
  56. package/es/calculator/workers/scatter-calculator-worker.js +0 -80
  57. package/es/calculator/workers/trend-calculator-worker.js +0 -108
  58. package/es/calculator/world-map-calculator.js +0 -124
  59. package/es/components/common-add-tool.js +0 -28
  60. package/es/components/dialog/chart-addition-edit-dialog.js +0 -90
  61. package/es/components/dialog/chart-addition-widgets/chart-selector.js +0 -259
  62. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +0 -83
  63. package/es/components/dialog/statistic-types-dialog/index.css +0 -14
  64. package/es/components/dialog/statistic-types-dialog/index.js +0 -62
  65. package/es/components/popover/color-rules/color-rule.js +0 -183
  66. package/es/components/popover/color-rules/index.js +0 -87
  67. package/es/components/popover/color-rules/rule-filters/filter.js +0 -221
  68. package/es/components/popover/color-rules/rule-filters/index.css +0 -210
  69. package/es/components/popover/color-rules/rule-filters/index.js +0 -97
  70. package/es/components/popover/color-rules/rule-filters/number-input.js +0 -78
  71. package/es/components/popover/color-rules-popover.js +0 -217
  72. package/es/components/popover/color-selector-popover.js +0 -82
  73. package/es/components/seatable-radio/index.css +0 -51
  74. package/es/components/seatable-radio/index.js +0 -35
  75. package/es/custom-g2.js +0 -644
  76. package/es/model/bar-group.js +0 -58
  77. package/es/model/bar.js +0 -47
  78. package/es/model/base-model.js +0 -18
  79. package/es/model/basic-number-card.js +0 -25
  80. package/es/model/combination.js +0 -48
  81. package/es/model/compare-bar.js +0 -56
  82. package/es/model/completeness-group.js +0 -31
  83. package/es/model/completeness.js +0 -25
  84. package/es/model/custom-bar.js +0 -25
  85. package/es/model/dashboard.js +0 -20
  86. package/es/model/generic-model.js +0 -222
  87. package/es/model/heat-map.js +0 -33
  88. package/es/model/horizontal-bar-group.js +0 -55
  89. package/es/model/horizontal-bar.js +0 -47
  90. package/es/model/index.js +0 -187
  91. package/es/model/map.js +0 -38
  92. package/es/model/mirror.js +0 -33
  93. package/es/model/pie.js +0 -38
  94. package/es/model/ring.js +0 -40
  95. package/es/model/scatter.js +0 -22
  96. package/es/model/table.js +0 -32
  97. package/es/model/trend.js +0 -32
  98. package/es/model/world-map.js +0 -34
  99. package/es/stat-editor/chart-name-editor.js +0 -68
  100. package/es/stat-editor/index.js +0 -75
  101. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +0 -153
  102. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +0 -422
  103. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +0 -203
  104. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +0 -23
  105. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +0 -104
  106. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +0 -334
  107. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +0 -119
  108. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +0 -132
  109. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +0 -240
  110. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +0 -89
  111. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +0 -138
  112. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +0 -331
  113. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +0 -143
  114. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +0 -109
  115. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +0 -153
  116. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +0 -144
  117. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +0 -214
  118. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +0 -121
  119. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +0 -172
  120. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +0 -366
  121. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +0 -142
  122. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +0 -150
  123. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +0 -473
  124. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +0 -182
  125. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +0 -564
  126. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +0 -112
  127. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +0 -87
  128. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +0 -187
  129. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +0 -300
  130. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +0 -113
  131. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +0 -289
  132. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +0 -58
  133. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +0 -359
  134. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +0 -48
  135. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +0 -121
  136. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +0 -143
  137. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +0 -269
  138. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +0 -104
  139. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +0 -366
  140. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +0 -55
  141. package/es/stat-editor/stat-settings/color-setting/color-picker.js +0 -130
  142. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +0 -374
  143. package/es/stat-editor/stat-settings/map/map-level.js +0 -72
  144. package/es/stat-editor/stat-settings/map/map-province-city.js +0 -151
  145. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +0 -108
  146. package/es/stat-editor/stat-settings/public-setting/base-settings.js +0 -154
  147. package/es/stat-editor/stat-settings/public-setting/calender.js +0 -125
  148. package/es/stat-editor/stat-settings/public-setting/column-settings.js +0 -24
  149. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +0 -62
  150. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +0 -61
  151. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +0 -35
  152. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +0 -60
  153. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +0 -123
  154. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +0 -33
  155. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +0 -29
  156. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +0 -82
  157. package/es/stat-view/area-chart.js +0 -551
  158. package/es/stat-view/bar-chart.js +0 -582
  159. package/es/stat-view/base-chart.js +0 -132
  160. package/es/stat-view/basic-number-card.js +0 -201
  161. package/es/stat-view/combination-chart.js +0 -546
  162. package/es/stat-view/compare-chart.js +0 -483
  163. package/es/stat-view/completeness-chart.js +0 -390
  164. package/es/stat-view/custom-bar.js +0 -418
  165. package/es/stat-view/dashboard-chart.js +0 -266
  166. package/es/stat-view/heat-map.js +0 -463
  167. package/es/stat-view/horizontal-bar-chart.js +0 -562
  168. package/es/stat-view/line-chart.js +0 -518
  169. package/es/stat-view/map.js +0 -448
  170. package/es/stat-view/mirror.js +0 -275
  171. package/es/stat-view/pie-chart.js +0 -290
  172. package/es/stat-view/pivot-table/index.js +0 -196
  173. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +0 -156
  174. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +0 -176
  175. package/es/stat-view/pivot-table/pivot-table-display-name.js +0 -215
  176. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +0 -132
  177. package/es/stat-view/pivot-table/two-dimension-table.js +0 -384
  178. package/es/stat-view/ring-chart.js +0 -392
  179. package/es/stat-view/scatter-chart.js +0 -306
  180. package/es/stat-view/treemap-chart.js +0 -253
  181. package/es/stat-view/trend-chart.js +0 -249
  182. package/es/stat-view/world-map.js +0 -431
  183. package/es/utils/basic-chart-utils.js +0 -29
  184. package/es/utils/cell-format.js +0 -115
  185. package/es/utils/collaborator.js +0 -50
  186. package/es/utils/color-utils.js +0 -134
  187. package/es/utils/column-utils.js +0 -110
  188. package/es/utils/column.js +0 -20
  189. package/es/utils/date-format.js +0 -71
  190. package/es/utils/map.js +0 -114
  191. package/es/utils/model.js +0 -19
  192. package/es/utils/row-utils.js +0 -134
  193. package/es/utils/search.js +0 -73
  194. package/es/utils/sql-utils.js +0 -359
  195. package/es/utils/stat-utils.js +0 -351
  196. 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;