dtable-statistic 4.3.2 → 4.3.3
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.
- package/es/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +110 -103
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +22 -15
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +56 -43
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +35 -28
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +42 -35
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +32 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +48 -40
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +59 -51
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +20 -12
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +56 -48
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +56 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +20 -12
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +33 -20
- package/es/stat-list/index.js +36 -28
- package/es/stat-view/area-chart.js +51 -44
- package/es/stat-view/bar-chart.js +55 -48
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +57 -50
- package/es/stat-view/compare-chart.js +47 -40
- package/es/stat-view/completeness-chart.js +37 -30
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +59 -52
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +47 -40
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +46 -39
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +45 -38
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +35 -27
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +67 -43
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +34 -24
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +67 -60
- package/es/utils/trend-utils.js +40 -32
- package/package.json +82 -125
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 _dtableStore = require("dtable-store");
|
|
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 {
|
|
9
16
|
constructor(_ref) {
|
|
10
17
|
let {
|
|
11
18
|
value,
|
|
@@ -30,11 +37,11 @@ class MapCalculator extends BaseCalculator {
|
|
|
30
37
|
summary_column
|
|
31
38
|
} = chart;
|
|
32
39
|
const table = this.getTableById(table_id);
|
|
33
|
-
const selectedColumn = geo_column && TableUtils.getTableColumnByKey(table, geo_column);
|
|
34
|
-
if (geo_column && (!selectedColumn || selectedColumn.type !== CellType.GEOLOCATION)) {
|
|
40
|
+
const selectedColumn = geo_column && _dtableStore.TableUtils.getTableColumnByKey(table, geo_column);
|
|
41
|
+
if (geo_column && (!selectedColumn || selectedColumn.type !== _dtableStore.CellType.GEOLOCATION)) {
|
|
35
42
|
return false;
|
|
36
43
|
}
|
|
37
|
-
if (summary_column && !TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
44
|
+
if (summary_column && !_dtableStore.TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
38
45
|
return false;
|
|
39
46
|
}
|
|
40
47
|
return true;
|
|
@@ -57,24 +64,24 @@ class MapCalculator extends BaseCalculator {
|
|
|
57
64
|
} = chart;
|
|
58
65
|
const selectedTable = this.getTableById(table_id);
|
|
59
66
|
const selectedView = this.getViewById(view_id, selectedTable);
|
|
60
|
-
const column = TableUtils.getTableColumnByKey(selectedTable, geo_column);
|
|
67
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, geo_column);
|
|
61
68
|
if (!column) return [];
|
|
62
69
|
const columnName = column.name;
|
|
63
70
|
const isAdvanced = summary_type === 'advanced';
|
|
64
|
-
const geoGranularity = fixMapGeoGranularity(chart);
|
|
65
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
|
|
66
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
67
|
-
const groupName = getSqlGroup(geoGranularity, column);
|
|
71
|
+
const geoGranularity = (0, _map.fixMapGeoGranularity)(chart);
|
|
72
|
+
const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
|
|
73
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
74
|
+
const groupName = (0, _sqlUtils.getSqlGroup)(geoGranularity, column);
|
|
68
75
|
let sqlString = '';
|
|
69
76
|
let summaryColumn;
|
|
70
77
|
let summaryColumnName = '';
|
|
71
78
|
if (isAdvanced) {
|
|
72
|
-
summaryColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
79
|
+
summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
73
80
|
if (!summaryColumn) {
|
|
74
81
|
return [];
|
|
75
82
|
}
|
|
76
83
|
summaryColumnName = summaryColumn.name;
|
|
77
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
84
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
78
85
|
sqlString = "select ".concat(groupName, ", ").concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, " limit 5000");
|
|
79
86
|
} else {
|
|
80
87
|
sqlString = "select ".concat(groupName, ", ").concat(method, "(`").concat(columnName, "`) from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, " limit 5000");
|
|
@@ -84,15 +91,15 @@ class MapCalculator extends BaseCalculator {
|
|
|
84
91
|
const data = result.data;
|
|
85
92
|
if (!data.results) return [];
|
|
86
93
|
const newResult = [];
|
|
87
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
94
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
88
95
|
const valueKey = isAdvanced ? "".concat(summaryColumnMethod) : "".concat(method, "(").concat(columnName, ")");
|
|
89
96
|
data.results.forEach(item => {
|
|
90
97
|
const currentValue = item[groupName];
|
|
91
98
|
let value = item[valueKey];
|
|
92
99
|
let formatted_value = value;
|
|
93
100
|
if (isAdvanced) {
|
|
94
|
-
value = formatNumericValue(value, summaryColumn);
|
|
95
|
-
formatted_value =
|
|
101
|
+
value = (0, _commonUtils.formatNumericValue)(value, summaryColumn);
|
|
102
|
+
formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, method);
|
|
96
103
|
}
|
|
97
104
|
if (currentValue) {
|
|
98
105
|
newResult.push({
|
|
@@ -107,4 +114,4 @@ class MapCalculator extends BaseCalculator {
|
|
|
107
114
|
return [];
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
|
-
|
|
117
|
+
var _default = exports.default = MapCalculator;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 _dtableStore = require("dtable-store");
|
|
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 {
|
|
7
14
|
constructor(_ref) {
|
|
8
15
|
let {
|
|
9
16
|
value,
|
|
@@ -29,13 +36,13 @@ class MirrorCalculator extends BaseCalculator {
|
|
|
29
36
|
group_column
|
|
30
37
|
} = chart;
|
|
31
38
|
const table = this.getTableById(table_id);
|
|
32
|
-
if (!TableUtils.getTableColumnByKey(table, column)) {
|
|
39
|
+
if (!_dtableStore.TableUtils.getTableColumnByKey(table, column)) {
|
|
33
40
|
return false;
|
|
34
41
|
}
|
|
35
|
-
if (summary_column && !TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
42
|
+
if (summary_column && !_dtableStore.TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
36
43
|
return false;
|
|
37
44
|
}
|
|
38
|
-
const selectedGroupColumn = TableUtils.getTableColumnByKey(table, group_column);
|
|
45
|
+
const selectedGroupColumn = _dtableStore.TableUtils.getTableColumnByKey(table, group_column);
|
|
39
46
|
if (!selectedGroupColumn) return false;
|
|
40
47
|
const data = selectedGroupColumn.data || {};
|
|
41
48
|
const options = data.options || [];
|
|
@@ -62,22 +69,22 @@ class MirrorCalculator extends BaseCalculator {
|
|
|
62
69
|
const selectedTable = this.getTableById(table_id);
|
|
63
70
|
const selectedView = this.getViewById(view_id, selectedTable);
|
|
64
71
|
let sqlString = '';
|
|
65
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, column);
|
|
72
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column);
|
|
66
73
|
const columnName = selectedColumn.name;
|
|
67
|
-
const selectedGroupColumn = TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
74
|
+
const selectedGroupColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
68
75
|
const groupColumnName = selectedGroupColumn.name;
|
|
69
76
|
const isAdvanced = summary_type === 'advanced';
|
|
70
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
|
|
71
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
77
|
+
const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summary_method] : 'COUNT';
|
|
78
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
72
79
|
let summaryColumnName = '',
|
|
73
80
|
summaryColumn;
|
|
74
81
|
if (isAdvanced) {
|
|
75
|
-
summaryColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
82
|
+
summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
76
83
|
if (!summaryColumn) {
|
|
77
84
|
return [];
|
|
78
85
|
}
|
|
79
86
|
summaryColumnName = summaryColumn.name;
|
|
80
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
87
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
81
88
|
sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
|
|
82
89
|
} else {
|
|
83
90
|
sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(method, "(`").concat(columnName, "`) from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
|
|
@@ -87,14 +94,14 @@ class MirrorCalculator extends BaseCalculator {
|
|
|
87
94
|
const data = result.data;
|
|
88
95
|
if (!data.results) return [];
|
|
89
96
|
const newResult = [];
|
|
90
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
97
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
91
98
|
const valueKey = isAdvanced ? "".concat(summaryColumnMethod) : "".concat(method, "(").concat(columnName, ")");
|
|
92
99
|
const groupData = this.getGroupData(data.results, selectedGroupColumn);
|
|
93
100
|
if (groupData.length > 0) {
|
|
94
101
|
const groupData0 = groupData[0] || {};
|
|
95
102
|
const groupData1 = groupData[1] || {};
|
|
96
103
|
data.results.forEach(item => {
|
|
97
|
-
const label =
|
|
104
|
+
const label = _statUtils.default.getGroupLabel(item[column], item, selectedColumn, '', '', this.value);
|
|
98
105
|
const groupValue = item[group_column];
|
|
99
106
|
const equal2GroupData0 = groupData0.id === groupValue;
|
|
100
107
|
const equal2GroupData1 = groupData1.id === groupValue;
|
|
@@ -102,8 +109,8 @@ class MirrorCalculator extends BaseCalculator {
|
|
|
102
109
|
let value = item[valueKey];
|
|
103
110
|
let formattedValue = value;
|
|
104
111
|
if (isAdvanced) {
|
|
105
|
-
value = formatNumericValue(value, summaryColumn);
|
|
106
|
-
formattedValue =
|
|
112
|
+
value = (0, _commonUtils.formatNumericValue)(value, summaryColumn);
|
|
113
|
+
formattedValue = _statUtils.default.getFormattedValue(value, summaryColumn, summary_method);
|
|
107
114
|
}
|
|
108
115
|
newResult.push({
|
|
109
116
|
name: label,
|
|
@@ -150,4 +157,4 @@ class MirrorCalculator extends BaseCalculator {
|
|
|
150
157
|
return groupList;
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
|
-
|
|
160
|
+
var _default = exports.default = MirrorCalculator;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 _dtableStore = require("dtable-store");
|
|
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 {
|
|
6
13
|
constructor(_ref) {
|
|
7
14
|
let {
|
|
8
15
|
value,
|
|
@@ -26,7 +33,7 @@ class NumberCardCalculator extends BaseCalculator {
|
|
|
26
33
|
numeric_column
|
|
27
34
|
} = chart;
|
|
28
35
|
const table = this.getTableById(table_id);
|
|
29
|
-
if (!TableUtils.getTableColumnByKey(table, numeric_column)) {
|
|
36
|
+
if (!_dtableStore.TableUtils.getTableColumnByKey(table, numeric_column)) {
|
|
30
37
|
return false;
|
|
31
38
|
}
|
|
32
39
|
return true;
|
|
@@ -47,9 +54,9 @@ class NumberCardCalculator extends BaseCalculator {
|
|
|
47
54
|
} = chart;
|
|
48
55
|
const selectedTable = this.getTableById(table_id);
|
|
49
56
|
const selectedView = this.getViewById(view_id, selectedTable);
|
|
50
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, numeric_column);
|
|
51
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
52
|
-
const summaryColumnMethod = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[summary_method], selectedColumn.name);
|
|
57
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, numeric_column);
|
|
58
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
59
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summary_method], selectedColumn.name);
|
|
53
60
|
const sqlString = "select ".concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " limit 5000");
|
|
54
61
|
const result = await this.sqlQuery(sqlString);
|
|
55
62
|
if (result.status === 200 && result.data.success) {
|
|
@@ -64,4 +71,4 @@ class NumberCardCalculator extends BaseCalculator {
|
|
|
64
71
|
return 0;
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
|
|
74
|
+
var _default = exports.default = NumberCardCalculator;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
+
var _dtableStore = require("dtable-store");
|
|
10
|
+
var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
|
|
11
|
+
var _constants = require("../constants");
|
|
12
|
+
var _commonUtils = require("../utils/common-utils");
|
|
13
|
+
var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
|
|
14
|
+
var _rowUtils = require("../utils/row-utils");
|
|
15
|
+
class PivotTableCalculator extends _baseCalculator.default {
|
|
9
16
|
constructor(_ref) {
|
|
10
17
|
let {
|
|
11
18
|
value,
|
|
@@ -33,13 +40,13 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
33
40
|
summary_columns_option
|
|
34
41
|
} = chart;
|
|
35
42
|
const table = this.getTableById(table_id);
|
|
36
|
-
if (!groupby_column_key || !TableUtils.getTableColumnByKey(table, groupby_column_key)) {
|
|
43
|
+
if (!groupby_column_key || !_dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key)) {
|
|
37
44
|
return false;
|
|
38
45
|
}
|
|
39
|
-
if (column_groupby_column_key && !TableUtils.getTableColumnByKey(table, column_groupby_column_key)) {
|
|
46
|
+
if (column_groupby_column_key && !_dtableStore.TableUtils.getTableColumnByKey(table, column_groupby_column_key)) {
|
|
40
47
|
return false;
|
|
41
48
|
}
|
|
42
|
-
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
49
|
+
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
43
50
|
const summaryColumnsKeys = summary_columns_option ? summary_columns_option.map(item => item.key) : [];
|
|
44
51
|
if (!table.columns.find(column => column.key === summary_column_key || summaryColumnsKeys.includes(column.key))) {
|
|
45
52
|
return false;
|
|
@@ -64,9 +71,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
64
71
|
} = chart;
|
|
65
72
|
const table = this.getTableById(table_id);
|
|
66
73
|
const view = this.getViewById(view_id, table);
|
|
67
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
68
|
-
const columnGroupbyColumn = TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
69
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
74
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
75
|
+
const columnGroupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
76
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
70
77
|
const sqlMap = this.generateSqlFromChart(chart, table, view);
|
|
71
78
|
const columnMap = {
|
|
72
79
|
groupbyColumn,
|
|
@@ -94,7 +101,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
94
101
|
groupby_column_key
|
|
95
102
|
} = chart;
|
|
96
103
|
if (!groupby_column_key) return '';
|
|
97
|
-
const condition = filter2SqlCondition(table, view);
|
|
104
|
+
const condition = (0, _dtableStore.filter2SqlCondition)(table, view);
|
|
98
105
|
if (!column_groupby_column_key) {
|
|
99
106
|
return this.oneDimensionStatisticTable2sql(chart, condition);
|
|
100
107
|
}
|
|
@@ -113,7 +120,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
113
120
|
summary_columns_option
|
|
114
121
|
} = chart;
|
|
115
122
|
const table = this.getTableById(table_id);
|
|
116
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
123
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
117
124
|
if (!groupbyColumn) return '';
|
|
118
125
|
const {
|
|
119
126
|
name: sqlGroupbyColumnName,
|
|
@@ -123,7 +130,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
123
130
|
geolocationGranularity: groupby_geolocation_granularity
|
|
124
131
|
});
|
|
125
132
|
let tableName = "`".concat(table.name, "`");
|
|
126
|
-
if (summary_type === SUMMARY_TYPE.COUNT) {
|
|
133
|
+
if (summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
127
134
|
const {
|
|
128
135
|
name: sqlSummaryColumnName,
|
|
129
136
|
key: sqlSummaryColumnKey
|
|
@@ -139,8 +146,8 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
139
146
|
let summaries = [];
|
|
140
147
|
let summaryColumnOptions = [];
|
|
141
148
|
const summaryMethod = summary_method;
|
|
142
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
143
|
-
if (summaryColumn && (isNumericColumn(summaryColumn) || isDateColumn(summaryColumn))) {
|
|
149
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
150
|
+
if (summaryColumn && ((0, _dtableStore.isNumericColumn)(summaryColumn) || (0, _dtableStore.isDateColumn)(summaryColumn))) {
|
|
144
151
|
const {
|
|
145
152
|
name: sqlSummaryMethodColumnName,
|
|
146
153
|
key: sqlSummaryMethodColumnKey
|
|
@@ -157,9 +164,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
157
164
|
key,
|
|
158
165
|
method
|
|
159
166
|
} = option;
|
|
160
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, key);
|
|
167
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, key);
|
|
161
168
|
const summaryMethod = method;
|
|
162
|
-
if (summaryColumn && (isNumericColumn(summaryColumn) || isDateColumn(summaryColumn))) {
|
|
169
|
+
if (summaryColumn && ((0, _dtableStore.isNumericColumn)(summaryColumn) || (0, _dtableStore.isDateColumn)(summaryColumn))) {
|
|
163
170
|
const {
|
|
164
171
|
name: sqlSummaryMethodColumnName,
|
|
165
172
|
key: sqlSummaryMethodColumnKey
|
|
@@ -185,7 +192,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
185
192
|
const validStatisticNumericColumnKeys = [...new Set(statisticNumericColumnKeys)];
|
|
186
193
|
let sqlNumericColumns = [];
|
|
187
194
|
let summaries = [];
|
|
188
|
-
validStatisticNumericColumnKeys.map(key => TableUtils.getTableColumnByKey(table, key)).filter(column => column && (isDateColumn(column) || isNumericColumn(column))).forEach(column => {
|
|
195
|
+
validStatisticNumericColumnKeys.map(key => _dtableStore.TableUtils.getTableColumnByKey(table, key)).filter(column => column && ((0, _dtableStore.isDateColumn)(column) || (0, _dtableStore.isNumericColumn)(column))).forEach(column => {
|
|
189
196
|
const {
|
|
190
197
|
name: sqlNumericColumn,
|
|
191
198
|
key: sqlNumericColumnKey
|
|
@@ -222,9 +229,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
222
229
|
} = chart;
|
|
223
230
|
const table = this.getTableById(table_id);
|
|
224
231
|
let tableName = "`".concat(table.name, "`");
|
|
225
|
-
const columnGroupbyColumn = TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
232
|
+
const columnGroupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
226
233
|
if (!columnGroupbyColumn) return this.oneDimensionStatisticTable2sql(chart, table, tableName, condition);
|
|
227
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
234
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
228
235
|
if (!groupbyColumn) return '';
|
|
229
236
|
const {
|
|
230
237
|
name: sqlGroupbyColumnName,
|
|
@@ -242,7 +249,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
242
249
|
});
|
|
243
250
|
let sqlSummaryColumnName;
|
|
244
251
|
let sqlSummaryColumnKey;
|
|
245
|
-
if (summary_type === SUMMARY_TYPE.COUNT) {
|
|
252
|
+
if (summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
246
253
|
const {
|
|
247
254
|
name,
|
|
248
255
|
key
|
|
@@ -251,7 +258,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
251
258
|
sqlSummaryColumnKey = key;
|
|
252
259
|
} else {
|
|
253
260
|
const summaryMethod = summary_method;
|
|
254
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
261
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
255
262
|
const {
|
|
256
263
|
name,
|
|
257
264
|
key
|
|
@@ -260,7 +267,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
260
267
|
sqlSummaryColumnKey = key;
|
|
261
268
|
if (column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
262
269
|
const sqlSummaryMultipleNumericColumnName = Array.isArray(summary_columns_option) ? summary_columns_option.forEach(item => {
|
|
263
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, item.key) || {};
|
|
270
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, item.key) || {};
|
|
264
271
|
const {
|
|
265
272
|
name
|
|
266
273
|
} = this.summaryMethodColumn2SqlColumn(item.method, summaryColumn);
|
|
@@ -275,9 +282,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
275
282
|
key,
|
|
276
283
|
method
|
|
277
284
|
} = option;
|
|
278
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, key);
|
|
285
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, key);
|
|
279
286
|
const summaryMethod = method;
|
|
280
|
-
if (summaryColumn && (isNumericColumn(summaryColumn) || isDateColumn(summaryColumn))) {
|
|
287
|
+
if (summaryColumn && ((0, _dtableStore.isNumericColumn)(summaryColumn) || (0, _dtableStore.isDateColumn)(summaryColumn))) {
|
|
281
288
|
const {
|
|
282
289
|
name: sqlSummaryMethodColumnName
|
|
283
290
|
} = this.summaryMethodColumn2SqlColumn(summaryMethod, summaryColumn);
|
|
@@ -319,7 +326,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
319
326
|
} = chart;
|
|
320
327
|
let pivot_columns = [];
|
|
321
328
|
let pivot_rows = [];
|
|
322
|
-
const isCount = summary_type === SUMMARY_TYPE.COUNT;
|
|
329
|
+
const isCount = summary_type === _constants.SUMMARY_TYPE.COUNT;
|
|
323
330
|
if (isCount) {
|
|
324
331
|
const {
|
|
325
332
|
sqlGroupbyColumnKey,
|
|
@@ -389,9 +396,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
389
396
|
summaryColumn,
|
|
390
397
|
summaryMethod
|
|
391
398
|
}, allTotal[totalKey], value);
|
|
392
|
-
if (summaryColumn && isDateColumn(summaryColumn)) {
|
|
399
|
+
if (summaryColumn && (0, _dtableStore.isDateColumn)(summaryColumn)) {
|
|
393
400
|
rowTotal[totalKey] = value;
|
|
394
|
-
} else if (summaryColumn && isNumericColumn(summaryColumn)) {
|
|
401
|
+
} else if (summaryColumn && (0, _dtableStore.isNumericColumn)(summaryColumn)) {
|
|
395
402
|
rowTotal[totalKey] = rowTotal[totalKey] + value;
|
|
396
403
|
}
|
|
397
404
|
});
|
|
@@ -454,7 +461,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
454
461
|
let pivot_columns = [];
|
|
455
462
|
let pivot_rows = [];
|
|
456
463
|
let pivot_columns_total = {};
|
|
457
|
-
const isRowGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
464
|
+
const isRowGroupbyColumnDataAsAnArray = !!_constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
458
465
|
sqlRows.forEach(row => {
|
|
459
466
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
460
467
|
const groupbyColumnOriginalLabel = this.getOriginalLabel(groupbyColumn, sqlGroupbyColumnKey, row, groupby_geolocation_granularity, groupby_date_granularity);
|
|
@@ -493,11 +500,11 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
493
500
|
key,
|
|
494
501
|
method
|
|
495
502
|
} = columnOption;
|
|
496
|
-
const column = TableUtils.getTableColumnByKey(selectedTable, columnOption.key);
|
|
503
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, columnOption.key);
|
|
497
504
|
const {
|
|
498
505
|
name
|
|
499
506
|
} = this.summaryMethodColumn2SqlColumn(columnOption.method, column, true);
|
|
500
|
-
if (column && isNumericColumn(column)) {
|
|
507
|
+
if (column && (0, _dtableStore.isNumericColumn)(column)) {
|
|
501
508
|
pivot_summary_multiple_columns.push({
|
|
502
509
|
key,
|
|
503
510
|
method,
|
|
@@ -528,9 +535,9 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
528
535
|
} = column;
|
|
529
536
|
const validColumnName = "`".concat(name, "`");
|
|
530
537
|
switch (type) {
|
|
531
|
-
case CellType.DATE:
|
|
532
|
-
case CellType.MTIME:
|
|
533
|
-
case CellType.CTIME:
|
|
538
|
+
case _dtableStore.CellType.DATE:
|
|
539
|
+
case _dtableStore.CellType.MTIME:
|
|
540
|
+
case _dtableStore.CellType.CTIME:
|
|
534
541
|
{
|
|
535
542
|
const validDateGranularity = dateGranularity && dateGranularity.toUpperCase();
|
|
536
543
|
if (validDateGranularity === 'DAY') {
|
|
@@ -581,7 +588,7 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
581
588
|
key: sqlColumnName
|
|
582
589
|
};
|
|
583
590
|
}
|
|
584
|
-
case CellType.GEOLOCATION:
|
|
591
|
+
case _dtableStore.CellType.GEOLOCATION:
|
|
585
592
|
{
|
|
586
593
|
let sqlColumnName;
|
|
587
594
|
if (geolocationGranularity === 'province') {
|
|
@@ -611,37 +618,37 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
611
618
|
const columnName = column.name;
|
|
612
619
|
const isUseSingleQuote = useSingleQuote ? false : true;
|
|
613
620
|
return {
|
|
614
|
-
name: getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[summaryMethod], columnName, isUseSingleQuote),
|
|
615
|
-
key: getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[summaryMethod], columnName)
|
|
621
|
+
name: (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summaryMethod], columnName, isUseSingleQuote),
|
|
622
|
+
key: (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summaryMethod], columnName)
|
|
616
623
|
};
|
|
617
624
|
}
|
|
618
625
|
getOriginalLabel(groupColumn, groupName, statRow, groupby_date_granularity, groupby_geolocation_granularity) {
|
|
619
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
620
|
-
if (isTimeColumn || groupColumn.type === CellType.GEOLOCATION) {
|
|
626
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
627
|
+
if (isTimeColumn || groupColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
621
628
|
return statRow[groupName];
|
|
622
629
|
}
|
|
623
630
|
const currentGroupLabel = statRow[groupColumn.key];
|
|
624
|
-
return
|
|
631
|
+
return _statUtils.default.getGroupLabel(currentGroupLabel, statRow, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
|
|
625
632
|
}
|
|
626
633
|
getOriginalName(groupColumn, originalLabel) {
|
|
627
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
628
|
-
if (isTimeColumn || groupColumn.type === CellType.GEOLOCATION) {
|
|
634
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
635
|
+
if (isTimeColumn || groupColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
629
636
|
return originalLabel;
|
|
630
637
|
}
|
|
631
638
|
let {
|
|
632
639
|
type: columnType
|
|
633
640
|
} = groupColumn;
|
|
634
|
-
if (columnType === CellType.MULTIPLE_SELECT || columnType === CellType.COLLABORATOR) {
|
|
641
|
+
if (columnType === _dtableStore.CellType.MULTIPLE_SELECT || columnType === _dtableStore.CellType.COLLABORATOR) {
|
|
635
642
|
return Array.isArray(originalLabel) ? originalLabel[0] : null;
|
|
636
643
|
}
|
|
637
644
|
return originalLabel;
|
|
638
645
|
}
|
|
639
646
|
getLabel(groupColumn, originalLabel) {
|
|
640
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
641
|
-
if (isTimeColumn || groupColumn.type === CellType.GEOLOCATION) {
|
|
647
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
648
|
+
if (isTimeColumn || groupColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
642
649
|
return originalLabel;
|
|
643
650
|
}
|
|
644
|
-
return getFormattedLabel(groupColumn, originalLabel, this.value.collaborators);
|
|
651
|
+
return (0, _rowUtils.getFormattedLabel)(groupColumn, originalLabel, this.value.collaborators);
|
|
645
652
|
}
|
|
646
653
|
initTotal(summaryMethod) {
|
|
647
654
|
if (summaryMethod === 'SUM' || summaryMethod === 'DISTINCT_VALUES') return 0;
|
|
@@ -652,31 +659,31 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
652
659
|
summaryMethod,
|
|
653
660
|
summaryColumn
|
|
654
661
|
} = _ref2;
|
|
655
|
-
if (summaryColumn && isDateColumn(summaryColumn)) {
|
|
656
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Max) {
|
|
662
|
+
if (summaryColumn && (0, _dtableStore.isDateColumn)(summaryColumn)) {
|
|
663
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Max) {
|
|
657
664
|
if (currentValue && nextValue) {
|
|
658
|
-
return
|
|
665
|
+
return (0, _dayjs.default)(currentValue).isBefore(nextValue) ? nextValue : currentValue;
|
|
659
666
|
}
|
|
660
667
|
if (!currentValue && nextValue) {
|
|
661
668
|
return nextValue;
|
|
662
669
|
}
|
|
663
670
|
return currentValue;
|
|
664
671
|
}
|
|
665
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Min) {
|
|
672
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Min) {
|
|
666
673
|
if (currentValue && nextValue) {
|
|
667
|
-
return
|
|
674
|
+
return (0, _dayjs.default)(currentValue).isBefore(nextValue) ? currentValue : nextValue;
|
|
668
675
|
}
|
|
669
676
|
if (!currentValue && nextValue) {
|
|
670
677
|
return nextValue;
|
|
671
678
|
}
|
|
672
679
|
return currentValue;
|
|
673
680
|
}
|
|
674
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
681
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Distinct_values) {
|
|
675
682
|
return (currentValue - 0 || 0) + (nextValue - 0 || 0);
|
|
676
683
|
}
|
|
677
684
|
return currentValue;
|
|
678
685
|
}
|
|
679
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Max || SUMMARY_METHOD_MAP.Min) {
|
|
686
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Max || _constants.SUMMARY_METHOD_MAP.Min) {
|
|
680
687
|
if (currentValue === null && nextValue === null) return null;
|
|
681
688
|
if (currentValue === null) return nextValue;
|
|
682
689
|
if (nextValue === null) return currentValue;
|
|
@@ -825,4 +832,4 @@ class PivotTableCalculator extends BaseCalculator {
|
|
|
825
832
|
return pivot_table_total;
|
|
826
833
|
}
|
|
827
834
|
}
|
|
828
|
-
|
|
835
|
+
var _default = exports.default = PivotTableCalculator;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 _dtableStore = require("dtable-store");
|
|
9
|
+
var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
|
|
10
|
+
var _rowUtils = require("../utils/row-utils");
|
|
11
|
+
var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
|
|
12
|
+
var _constants = require("../constants");
|
|
13
|
+
class ScatterCalculator extends _baseCalculator.default {
|
|
7
14
|
constructor(_ref) {
|
|
8
15
|
let {
|
|
9
16
|
value,
|
|
@@ -29,7 +36,7 @@ class ScatterCalculator extends BaseCalculator {
|
|
|
29
36
|
group_column
|
|
30
37
|
} = chart;
|
|
31
38
|
const table = this.getTableById(table_id);
|
|
32
|
-
if (!TableUtils.getTableColumnByKey(table, x_axis_column) || !TableUtils.getTableColumnByKey(table, y_axis_column) || !TableUtils.getTableColumnByKey(table, group_column)) {
|
|
39
|
+
if (!_dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column) || !_dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column) || !_dtableStore.TableUtils.getTableColumnByKey(table, group_column)) {
|
|
33
40
|
return false;
|
|
34
41
|
}
|
|
35
42
|
return true;
|
|
@@ -51,10 +58,10 @@ class ScatterCalculator extends BaseCalculator {
|
|
|
51
58
|
} = chart;
|
|
52
59
|
const selectedTable = this.getTableById(table_id);
|
|
53
60
|
const selectedView = this.getViewById(view_id, selectedTable);
|
|
54
|
-
const selectedXAxisColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column);
|
|
55
|
-
const selectedYAxisColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_column);
|
|
56
|
-
const selectedGroupColumn = TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
57
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
61
|
+
const selectedXAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column);
|
|
62
|
+
const selectedYAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_column);
|
|
63
|
+
const selectedGroupColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
64
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
58
65
|
const sqlString = "select `".concat(selectedXAxisColumn.name, "`, `").concat(selectedYAxisColumn.name, "`, `").concat(selectedGroupColumn.name, "` from `").concat(selectedTable.name, "` ").concat(sqlCondition, " limit 5000");
|
|
59
66
|
const result = await this.sqlQuery(sqlString);
|
|
60
67
|
if (result.status === 200 && result.data.success) {
|
|
@@ -75,8 +82,8 @@ class ScatterCalculator extends BaseCalculator {
|
|
|
75
82
|
}
|
|
76
83
|
getColumnValue(data, column) {
|
|
77
84
|
const tempValue = data[column.key];
|
|
78
|
-
const value =
|
|
79
|
-
return getFormattedLabel(column, value, this.value.collaborators);
|
|
85
|
+
const value = _statUtils.default.getGroupLabel(tempValue, data, column, _constants.DATE_GRANULARITY.DAY, '', this.value);
|
|
86
|
+
return (0, _rowUtils.getFormattedLabel)(column, value, this.value.collaborators);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
|
-
|
|
89
|
+
var _default = exports.default = ScatterCalculator;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
1
7
|
class ThreadManager {
|
|
2
8
|
constructor(threadCount) {
|
|
3
9
|
this.applyThread = async (id, workerConstructor) => {
|
|
@@ -48,4 +54,4 @@ class ThreadManager {
|
|
|
48
54
|
this.queue = [];
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
|
-
|
|
57
|
+
var _default = exports.default = ThreadManager;
|