dtable-statistic 4.3.4 → 4.3.6
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 +108 -101
- 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 +21 -14
- 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 +49 -41
- 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 +34 -27
- 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 +41 -34
- 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 +29 -21
- 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 +31 -23
- 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 +45 -37
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +27 -19
- 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 +26 -18
- 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 +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +55 -47
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +19 -11
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +53 -45
- 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 +28 -20
- 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 +55 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +19 -11
- 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 +28 -20
- package/es/stat-list/index.js +35 -27
- package/es/stat-view/area-chart.js +50 -43
- package/es/stat-view/bar-chart.js +54 -47
- 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 +56 -49
- package/es/stat-view/compare-chart.js +46 -39
- package/es/stat-view/completeness-chart.js +35 -28
- 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 +58 -51
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +46 -39
- 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 +72 -70
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +45 -38
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +44 -37
- 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 +34 -26
- 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 +65 -41
- 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 +33 -23
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +69 -67
- package/es/utils/trend-utils.js +40 -32
- package/package.json +3 -3
package/es/utils/sql-utils.js
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSqlString = exports.getSqlOrder = exports.getSqlGroup = exports.getPieChartSqlGroupName = void 0;
|
|
7
|
+
var _dtableStore = require("dtable-store");
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
const getSqlOrder = (sortType, groupName) => {
|
|
4
10
|
if (!sortType) {
|
|
5
11
|
return "order by ".concat(groupName);
|
|
6
12
|
}
|
|
7
13
|
return '';
|
|
8
14
|
};
|
|
9
|
-
|
|
15
|
+
exports.getSqlOrder = getSqlOrder;
|
|
16
|
+
const getSqlGroup = (granularity, column) => {
|
|
10
17
|
const {
|
|
11
18
|
name,
|
|
12
19
|
type
|
|
13
20
|
} = column;
|
|
14
21
|
let columnName = "`".concat(name, "`");
|
|
15
|
-
if (TIME_COLUMN_LIST.includes(type)) {
|
|
16
|
-
if (granularity && granularity.includes(STATISTICS_COUNT_TYPE.DAY)) {
|
|
22
|
+
if (_constants.TIME_COLUMN_LIST.includes(type)) {
|
|
23
|
+
if (granularity && granularity.includes(_constants.STATISTICS_COUNT_TYPE.DAY)) {
|
|
17
24
|
return "ISODATE(".concat(columnName, ")");
|
|
18
25
|
}
|
|
19
|
-
if (granularity === STATISTICS_COUNT_TYPE.WEEK) {
|
|
26
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.WEEK) {
|
|
20
27
|
return 'ISODATE(STARTOFWEEK(' + columnName + ', "monday"))';
|
|
21
28
|
}
|
|
22
|
-
if (granularity === STATISTICS_COUNT_TYPE.MONTH) {
|
|
29
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.MONTH) {
|
|
23
30
|
return "ISOMONTH(".concat(columnName, ")");
|
|
24
31
|
}
|
|
25
|
-
if (granularity === STATISTICS_COUNT_TYPE.QUARTER) {
|
|
32
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.QUARTER) {
|
|
26
33
|
return "CONCATENATE(year(".concat(columnName, "), \"-Q\", quarter(").concat(columnName, "))");
|
|
27
34
|
}
|
|
28
35
|
return "YEAR(".concat(columnName, ")");
|
|
29
|
-
} else if (type === CellType.GEOLOCATION) {
|
|
30
|
-
if (granularity === STATISTICS_COUNT_TYPE.PROVINCE) {
|
|
36
|
+
} else if (type === _dtableStore.CellType.GEOLOCATION) {
|
|
37
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.PROVINCE) {
|
|
31
38
|
return "PROVINCE(".concat(columnName, ")");
|
|
32
39
|
}
|
|
33
|
-
if (granularity === STATISTICS_COUNT_TYPE.CITY) {
|
|
40
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.CITY) {
|
|
34
41
|
return "CITY(".concat(columnName, ")");
|
|
35
42
|
}
|
|
36
|
-
if (granularity === STATISTICS_COUNT_TYPE.DISTRICT) {
|
|
43
|
+
if (granularity === _constants.STATISTICS_COUNT_TYPE.DISTRICT) {
|
|
37
44
|
return "DISTRICT(".concat(columnName, ")");
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
47
|
return "`".concat(columnName, "`");
|
|
41
48
|
};
|
|
42
|
-
|
|
49
|
+
exports.getSqlGroup = getSqlGroup;
|
|
50
|
+
const getPieChartSqlGroupName = (statisticRecord, selectedColumn, groupName) => {
|
|
43
51
|
const {
|
|
44
52
|
original_name_list,
|
|
45
53
|
name_list
|
|
@@ -56,7 +64,8 @@ export const getPieChartSqlGroupName = (statisticRecord, selectedColumn, groupNa
|
|
|
56
64
|
});
|
|
57
65
|
return sqlString;
|
|
58
66
|
};
|
|
59
|
-
|
|
67
|
+
exports.getPieChartSqlGroupName = getPieChartSqlGroupName;
|
|
68
|
+
const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
60
69
|
let {
|
|
61
70
|
isColumn,
|
|
62
71
|
isCurrentView,
|
|
@@ -71,7 +80,7 @@ export const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
71
80
|
type
|
|
72
81
|
} = statItem;
|
|
73
82
|
const selectedTable = getTableById(table_id);
|
|
74
|
-
const selectedView = Views.getViewById(selectedTable.views, view_id);
|
|
83
|
+
const selectedView = _dtableStore.Views.getViewById(selectedTable.views, view_id);
|
|
75
84
|
const {
|
|
76
85
|
groupName,
|
|
77
86
|
selectedColumn,
|
|
@@ -80,7 +89,7 @@ export const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
80
89
|
} = getDatabaseGroupName(statItem, selectedTable, {
|
|
81
90
|
isCurrentView
|
|
82
91
|
});
|
|
83
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
92
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
84
93
|
const isGroup = column_groupby_column_key && !column_groupby_multiple_numeric_column;
|
|
85
94
|
const {
|
|
86
95
|
name,
|
|
@@ -89,7 +98,7 @@ export const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
89
98
|
group_name
|
|
90
99
|
} = statisticRecord;
|
|
91
100
|
let sqlName = getSqlGroupName(name, original_name, selectedColumn);
|
|
92
|
-
if ((type === STAT_TYPE.PIE || type === STAT_TYPE.RING) && original_name === 'Others') {
|
|
101
|
+
if ((type === _constants.STAT_TYPE.PIE || type === _constants.STAT_TYPE.RING) && original_name === 'Others') {
|
|
93
102
|
sqlName = getPieChartSqlGroupName(statisticRecord, selectedColumn, groupName);
|
|
94
103
|
}
|
|
95
104
|
let sqlGroupName;
|
|
@@ -97,7 +106,7 @@ export const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
97
106
|
sqlGroupName = getSqlGroupName(group_name, group_original_name, columnSelectedColumn);
|
|
98
107
|
}
|
|
99
108
|
let sqlString;
|
|
100
|
-
if (STAT_TYPE.PIVOT_TABLE === type) {
|
|
109
|
+
if (_constants.STAT_TYPE.PIVOT_TABLE === type) {
|
|
101
110
|
let pivotGroupName = "".concat(isGroup ? "".concat(columnGroupName, "=").concat(sqlGroupName) : '');
|
|
102
111
|
if (isColumn) {
|
|
103
112
|
if (sqlCondition && pivotGroupName) {
|
|
@@ -129,11 +138,12 @@ export const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
129
138
|
}
|
|
130
139
|
return sqlString;
|
|
131
140
|
};
|
|
141
|
+
exports.getSqlString = getSqlString;
|
|
132
142
|
const getSqlGroupName = (name, original_name, column) => {
|
|
133
143
|
const {
|
|
134
144
|
type
|
|
135
145
|
} = column || {};
|
|
136
|
-
if (type === CellType.SINGLE_SELECT || type === CellType.MULTIPLE_SELECT) {
|
|
146
|
+
if (type === _dtableStore.CellType.SINGLE_SELECT || type === _dtableStore.CellType.MULTIPLE_SELECT) {
|
|
137
147
|
return "'".concat(name, "'");
|
|
138
148
|
}
|
|
139
149
|
const newName = original_name ? original_name : name;
|
|
@@ -148,10 +158,10 @@ const getGroupName = (selectedColumn, _ref2) => {
|
|
|
148
158
|
groupby_geolocation_granularity
|
|
149
159
|
} = _ref2;
|
|
150
160
|
let groupName = "`".concat(selectedColumn.name, "`");
|
|
151
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(selectedColumn.type);
|
|
161
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(selectedColumn.type);
|
|
152
162
|
if (isTimeColumn) {
|
|
153
163
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
154
|
-
} else if (selectedColumn.type === CellType.GEOLOCATION) {
|
|
164
|
+
} else if (selectedColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
155
165
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
156
166
|
}
|
|
157
167
|
return groupName;
|
|
@@ -165,18 +175,18 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
165
175
|
const type = statItem.type;
|
|
166
176
|
let groupName, selectedColumn, columnGroupName, columnSelectedColumn;
|
|
167
177
|
switch (type) {
|
|
168
|
-
case STAT_TYPE.BAR:
|
|
169
|
-
case STAT_TYPE.BAR_GROUP:
|
|
170
|
-
case STAT_TYPE.BAR_STACK:
|
|
171
|
-
case STAT_TYPE.LINE:
|
|
172
|
-
case STAT_TYPE.PIE:
|
|
173
|
-
case STAT_TYPE.RING:
|
|
174
|
-
case STAT_TYPE.AREA_CHART:
|
|
175
|
-
case STAT_TYPE.AREA_GROUP_CHART:
|
|
176
|
-
case STAT_TYPE.TREEMAP:
|
|
177
|
-
case STAT_TYPE.HORIZONTAL_BAR:
|
|
178
|
-
case STAT_TYPE.HORIZONTAL_GROUP_BAR:
|
|
179
|
-
case STAT_TYPE.STACKED_HORIZONTAL_BAR:
|
|
178
|
+
case _constants.STAT_TYPE.BAR:
|
|
179
|
+
case _constants.STAT_TYPE.BAR_GROUP:
|
|
180
|
+
case _constants.STAT_TYPE.BAR_STACK:
|
|
181
|
+
case _constants.STAT_TYPE.LINE:
|
|
182
|
+
case _constants.STAT_TYPE.PIE:
|
|
183
|
+
case _constants.STAT_TYPE.RING:
|
|
184
|
+
case _constants.STAT_TYPE.AREA_CHART:
|
|
185
|
+
case _constants.STAT_TYPE.AREA_GROUP_CHART:
|
|
186
|
+
case _constants.STAT_TYPE.TREEMAP:
|
|
187
|
+
case _constants.STAT_TYPE.HORIZONTAL_BAR:
|
|
188
|
+
case _constants.STAT_TYPE.HORIZONTAL_GROUP_BAR:
|
|
189
|
+
case _constants.STAT_TYPE.STACKED_HORIZONTAL_BAR:
|
|
180
190
|
{
|
|
181
191
|
let groupby_column_key, groupby_date_granularity, groupby_geolocation_granularity;
|
|
182
192
|
const {
|
|
@@ -185,11 +195,11 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
185
195
|
column_groupby_date_granularity,
|
|
186
196
|
column_groupby_geolocation_granularity
|
|
187
197
|
} = statItem;
|
|
188
|
-
if (type === STAT_TYPE.PIE || type === STAT_TYPE.RING || type === STAT_TYPE.TREEMAP) {
|
|
198
|
+
if (type === _constants.STAT_TYPE.PIE || type === _constants.STAT_TYPE.RING || type === _constants.STAT_TYPE.TREEMAP) {
|
|
189
199
|
groupby_column_key = statItem.groupby_column_key;
|
|
190
200
|
groupby_date_granularity = statItem.groupby_date_granularity;
|
|
191
201
|
groupby_geolocation_granularity = statItem.groupby_geolocation_granularity;
|
|
192
|
-
} else if (type === STAT_TYPE.HORIZONTAL_BAR || type === STAT_TYPE.HORIZONTAL_GROUP_BAR || type === STAT_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
202
|
+
} else if (type === _constants.STAT_TYPE.HORIZONTAL_BAR || type === _constants.STAT_TYPE.HORIZONTAL_GROUP_BAR || type === _constants.STAT_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
193
203
|
groupby_column_key = statItem.vertical_axis_column_key;
|
|
194
204
|
groupby_date_granularity = statItem.vertical_axis_date_granularity;
|
|
195
205
|
groupby_geolocation_granularity = statItem.vertical_axis_geolocation_granularity;
|
|
@@ -199,117 +209,117 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
199
209
|
groupby_geolocation_granularity = statItem.x_axis_geolocation_granularity;
|
|
200
210
|
}
|
|
201
211
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
202
|
-
columnSelectedColumn = TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
|
|
212
|
+
columnSelectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
|
|
203
213
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
204
214
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
205
215
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
206
216
|
});
|
|
207
217
|
}
|
|
208
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
218
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
209
219
|
groupName = getGroupName(selectedColumn, {
|
|
210
220
|
groupby_date_granularity,
|
|
211
221
|
groupby_geolocation_granularity
|
|
212
222
|
});
|
|
213
223
|
break;
|
|
214
224
|
}
|
|
215
|
-
case STAT_TYPE.MAP:
|
|
216
|
-
case STAT_TYPE.MAP_BUBBLE:
|
|
225
|
+
case _constants.STAT_TYPE.MAP:
|
|
226
|
+
case _constants.STAT_TYPE.MAP_BUBBLE:
|
|
217
227
|
{
|
|
218
228
|
const {
|
|
219
229
|
geolocation_granularity,
|
|
220
230
|
geo_column
|
|
221
231
|
} = statItem;
|
|
222
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, geo_column);
|
|
232
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, geo_column);
|
|
223
233
|
groupName = getSqlGroup(geolocation_granularity, selectedColumn);
|
|
224
234
|
break;
|
|
225
235
|
}
|
|
226
|
-
case STAT_TYPE.WORLD_MAP:
|
|
227
|
-
case STAT_TYPE.WORLD_MAP_BUBBLE:
|
|
228
|
-
case STAT_TYPE.MIRROR:
|
|
236
|
+
case _constants.STAT_TYPE.WORLD_MAP:
|
|
237
|
+
case _constants.STAT_TYPE.WORLD_MAP_BUBBLE:
|
|
238
|
+
case _constants.STAT_TYPE.MIRROR:
|
|
229
239
|
{
|
|
230
240
|
const {
|
|
231
241
|
column
|
|
232
242
|
} = statItem;
|
|
233
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, column);
|
|
243
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column);
|
|
234
244
|
groupName = selectedColumn.name;
|
|
235
245
|
break;
|
|
236
246
|
}
|
|
237
|
-
case STAT_TYPE.HEAT_MAP:
|
|
247
|
+
case _constants.STAT_TYPE.HEAT_MAP:
|
|
238
248
|
{
|
|
239
249
|
const {
|
|
240
250
|
time_column
|
|
241
251
|
} = statItem;
|
|
242
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, time_column);
|
|
252
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, time_column);
|
|
243
253
|
groupName = "ISODATE(".concat(selectedColumn.name, ")");
|
|
244
254
|
break;
|
|
245
255
|
}
|
|
246
|
-
case STAT_TYPE.SCATTER:
|
|
256
|
+
case _constants.STAT_TYPE.SCATTER:
|
|
247
257
|
{
|
|
248
258
|
const {
|
|
249
259
|
group_column
|
|
250
260
|
} = statItem;
|
|
251
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
261
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
252
262
|
groupName = selectedColumn.name;
|
|
253
263
|
break;
|
|
254
264
|
}
|
|
255
|
-
case STAT_TYPE.BASIC_NUMBER_CARD:
|
|
265
|
+
case _constants.STAT_TYPE.BASIC_NUMBER_CARD:
|
|
256
266
|
{
|
|
257
267
|
// todo
|
|
258
268
|
break;
|
|
259
269
|
}
|
|
260
|
-
case STAT_TYPE.COMPARE_BAR:
|
|
270
|
+
case _constants.STAT_TYPE.COMPARE_BAR:
|
|
261
271
|
{
|
|
262
272
|
const {
|
|
263
273
|
x_axis_column_key,
|
|
264
274
|
x_axis_date_granularity
|
|
265
275
|
} = statItem;
|
|
266
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
276
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
267
277
|
groupName = getSqlGroup(x_axis_date_granularity, selectedColumn);
|
|
268
278
|
break;
|
|
269
279
|
}
|
|
270
|
-
case STAT_TYPE.COMBINATION_CHART:
|
|
280
|
+
case _constants.STAT_TYPE.COMBINATION_CHART:
|
|
271
281
|
{
|
|
272
282
|
const {
|
|
273
283
|
x_axis_column_key,
|
|
274
284
|
x_axis_date_granularity: groupby_date_granularity,
|
|
275
285
|
x_axis_geolocation_granularity: groupby_geolocation_granularity
|
|
276
286
|
} = statItem;
|
|
277
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
287
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
278
288
|
if (!selectedColumn) return [];
|
|
279
289
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
280
|
-
if (TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
290
|
+
if (_constants.TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
281
291
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
282
|
-
} else if (selectedColumn.type === CellType.GEOLOCATION) {
|
|
292
|
+
} else if (selectedColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
283
293
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
284
294
|
}
|
|
285
295
|
break;
|
|
286
296
|
}
|
|
287
|
-
case STAT_TYPE.TREND_CHART:
|
|
297
|
+
case _constants.STAT_TYPE.TREND_CHART:
|
|
288
298
|
{
|
|
289
299
|
const {
|
|
290
300
|
date_column,
|
|
291
301
|
date_granularity
|
|
292
302
|
} = statItem;
|
|
293
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, date_column);
|
|
303
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, date_column);
|
|
294
304
|
groupName = getSqlGroup(date_granularity, selectedColumn);
|
|
295
305
|
break;
|
|
296
306
|
}
|
|
297
|
-
case STAT_TYPE.COMPLETENESS_CHART:
|
|
298
|
-
case STAT_TYPE.GROUP_COMPLETENESS_CHART:
|
|
307
|
+
case _constants.STAT_TYPE.COMPLETENESS_CHART:
|
|
308
|
+
case _constants.STAT_TYPE.GROUP_COMPLETENESS_CHART:
|
|
299
309
|
{
|
|
300
310
|
const {
|
|
301
311
|
name_column
|
|
302
312
|
} = statItem;
|
|
303
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, name_column);
|
|
313
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, name_column);
|
|
304
314
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
305
315
|
break;
|
|
306
316
|
}
|
|
307
|
-
case STAT_TYPE.DASHBOARD:
|
|
317
|
+
case _constants.STAT_TYPE.DASHBOARD:
|
|
308
318
|
{
|
|
309
319
|
// todo
|
|
310
320
|
break;
|
|
311
321
|
}
|
|
312
|
-
case STAT_TYPE.PIVOT_TABLE:
|
|
322
|
+
case _constants.STAT_TYPE.PIVOT_TABLE:
|
|
313
323
|
{
|
|
314
324
|
let {
|
|
315
325
|
groupby_column_key,
|
|
@@ -321,13 +331,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
321
331
|
column_groupby_multiple_numeric_column
|
|
322
332
|
} = statItem;
|
|
323
333
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
324
|
-
columnSelectedColumn = TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
|
|
334
|
+
columnSelectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
|
|
325
335
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
326
336
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
327
337
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
328
338
|
});
|
|
329
339
|
}
|
|
330
|
-
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
340
|
+
selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
331
341
|
groupName = getGroupName(selectedColumn, {
|
|
332
342
|
groupby_date_granularity,
|
|
333
343
|
groupby_geolocation_granularity
|
package/es/utils/stat-utils.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _dtableStore = require("dtable-store");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _collaborator = require("./collaborator");
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
const SUPPORT_SORT_COLUMNS = [_dtableStore.CellType.TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.DATE, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.RATE];
|
|
11
12
|
class StatUtils {
|
|
12
13
|
static getGroupLabel(cellValue, formulaRow, column, dateGranularity, geoGranularity, value) {
|
|
13
14
|
let {
|
|
@@ -16,20 +17,20 @@ class StatUtils {
|
|
|
16
17
|
data
|
|
17
18
|
} = column;
|
|
18
19
|
switch (type) {
|
|
19
|
-
case CellType.TEXT:
|
|
20
|
+
case _dtableStore.CellType.TEXT:
|
|
20
21
|
{
|
|
21
22
|
return cellValue || null;
|
|
22
23
|
}
|
|
23
|
-
case CellType.NUMBER:
|
|
24
|
+
case _dtableStore.CellType.NUMBER:
|
|
24
25
|
{
|
|
25
26
|
if (!cellValue && cellValue !== 0) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
|
-
const number = getPrecisionNumber(cellValue, data);
|
|
29
|
+
const number = (0, _dtableStore.getPrecisionNumber)(cellValue, data);
|
|
29
30
|
let valueNumber = parseFloat(number);
|
|
30
|
-
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
31
|
+
return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
|
|
31
32
|
}
|
|
32
|
-
case CellType.SINGLE_SELECT:
|
|
33
|
+
case _dtableStore.CellType.SINGLE_SELECT:
|
|
33
34
|
{
|
|
34
35
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
35
36
|
if (isInvalidValue) {
|
|
@@ -37,20 +38,20 @@ class StatUtils {
|
|
|
37
38
|
}
|
|
38
39
|
return cellValue;
|
|
39
40
|
}
|
|
40
|
-
case CellType.DATE:
|
|
41
|
-
case CellType.CTIME:
|
|
42
|
-
case CellType.MTIME:
|
|
41
|
+
case _dtableStore.CellType.DATE:
|
|
42
|
+
case _dtableStore.CellType.CTIME:
|
|
43
|
+
case _dtableStore.CellType.MTIME:
|
|
43
44
|
{
|
|
44
45
|
if (!dateGranularity) {
|
|
45
|
-
return getDateDisplayString(cellValue);
|
|
46
|
+
return (0, _dtableStore.getDateDisplayString)(cellValue);
|
|
46
47
|
}
|
|
47
48
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
48
49
|
// TODO: fix the unknown word 'QUARTAR'
|
|
49
|
-
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
50
|
+
return _dtableStore.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
50
51
|
}
|
|
51
|
-
return DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
52
|
+
return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
52
53
|
}
|
|
53
|
-
case CellType.MULTIPLE_SELECT:
|
|
54
|
+
case _dtableStore.CellType.MULTIPLE_SELECT:
|
|
54
55
|
{
|
|
55
56
|
let options = data && data.options;
|
|
56
57
|
if (!Array.isArray(cellValue)) {
|
|
@@ -58,44 +59,45 @@ class StatUtils {
|
|
|
58
59
|
}
|
|
59
60
|
return cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
60
61
|
}
|
|
61
|
-
case CellType.COLLABORATOR:
|
|
62
|
+
case _dtableStore.CellType.COLLABORATOR:
|
|
62
63
|
{
|
|
63
|
-
|
|
64
|
+
if (!Array.isArray(cellValue)) return [];
|
|
65
|
+
return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
|
|
64
66
|
}
|
|
65
|
-
case CellType.CREATOR:
|
|
66
|
-
case CellType.LAST_MODIFIER:
|
|
67
|
+
case _dtableStore.CellType.CREATOR:
|
|
68
|
+
case _dtableStore.CellType.LAST_MODIFIER:
|
|
67
69
|
{
|
|
68
70
|
return cellValue ? cellValue : null;
|
|
69
71
|
}
|
|
70
|
-
case CellType.LINK_FORMULA:
|
|
71
|
-
case CellType.FORMULA:
|
|
72
|
+
case _dtableStore.CellType.LINK_FORMULA:
|
|
73
|
+
case _dtableStore.CellType.FORMULA:
|
|
72
74
|
{
|
|
73
75
|
if (!formulaRow) return '';
|
|
74
76
|
let formulaCellValue = formulaRow[key];
|
|
75
77
|
let {
|
|
76
78
|
result_type
|
|
77
79
|
} = data || {};
|
|
78
|
-
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
79
|
-
return getFormulaDisplayString(formulaCellValue, data, {
|
|
80
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
|
|
81
|
+
return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, {
|
|
80
82
|
tables: value.tables
|
|
81
83
|
}) || null;
|
|
82
84
|
}
|
|
83
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
84
|
-
return getPrecisionNumber(formulaCellValue, data);
|
|
85
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
|
|
86
|
+
return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data);
|
|
85
87
|
}
|
|
86
88
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
87
89
|
}
|
|
88
|
-
case CellType.GEOLOCATION:
|
|
90
|
+
case _dtableStore.CellType.GEOLOCATION:
|
|
89
91
|
{
|
|
90
92
|
const {
|
|
91
93
|
geo_format
|
|
92
94
|
} = data || {};
|
|
93
95
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
94
|
-
return getGeolocationDisplayString(cellValue, data);
|
|
96
|
+
return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data);
|
|
95
97
|
}
|
|
96
98
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
97
99
|
}
|
|
98
|
-
case CellType.LINK:
|
|
100
|
+
case _dtableStore.CellType.LINK:
|
|
99
101
|
{
|
|
100
102
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
101
103
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -103,11 +105,11 @@ class StatUtils {
|
|
|
103
105
|
}
|
|
104
106
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
105
107
|
}
|
|
106
|
-
case CellType.CHECKBOX:
|
|
108
|
+
case _dtableStore.CellType.CHECKBOX:
|
|
107
109
|
{
|
|
108
110
|
return String(!!cellValue);
|
|
109
111
|
}
|
|
110
|
-
case CellType.RATE:
|
|
112
|
+
case _dtableStore.CellType.RATE:
|
|
111
113
|
{
|
|
112
114
|
if (!cellValue) return null;
|
|
113
115
|
return cellValue + '';
|
|
@@ -125,7 +127,7 @@ class StatUtils {
|
|
|
125
127
|
} = column;
|
|
126
128
|
let sortType = 'up';
|
|
127
129
|
let option_id_index_map = {};
|
|
128
|
-
if (column_type === CellType.SINGLE_SELECT) {
|
|
130
|
+
if (column_type === _dtableStore.CellType.SINGLE_SELECT) {
|
|
129
131
|
const {
|
|
130
132
|
options
|
|
131
133
|
} = data || {};
|
|
@@ -148,7 +150,7 @@ class StatUtils {
|
|
|
148
150
|
}
|
|
149
151
|
if (SUPPORT_SORT_COLUMNS.includes(column_type)) {
|
|
150
152
|
switch (column_type) {
|
|
151
|
-
case CellType.NUMBER:
|
|
153
|
+
case _dtableStore.CellType.NUMBER:
|
|
152
154
|
{
|
|
153
155
|
if (current) {
|
|
154
156
|
current = current - 0;
|
|
@@ -156,42 +158,42 @@ class StatUtils {
|
|
|
156
158
|
if (next) {
|
|
157
159
|
next = next - 0;
|
|
158
160
|
}
|
|
159
|
-
return sortNumber(current, next, sortType);
|
|
161
|
+
return (0, _dtableStore.sortNumber)(current, next, sortType);
|
|
160
162
|
}
|
|
161
|
-
case CellType.DATE:
|
|
162
|
-
case CellType.CTIME:
|
|
163
|
-
case CellType.MTIME:
|
|
163
|
+
case _dtableStore.CellType.DATE:
|
|
164
|
+
case _dtableStore.CellType.CTIME:
|
|
165
|
+
case _dtableStore.CellType.MTIME:
|
|
164
166
|
{
|
|
165
|
-
return sortDate(current, next, sortType);
|
|
167
|
+
return (0, _dtableStore.sortDate)(current, next, sortType);
|
|
166
168
|
}
|
|
167
|
-
case CellType.SINGLE_SELECT:
|
|
168
|
-
case CellType.MULTIPLE_SELECT:
|
|
169
|
+
case _dtableStore.CellType.SINGLE_SELECT:
|
|
170
|
+
case _dtableStore.CellType.MULTIPLE_SELECT:
|
|
169
171
|
{
|
|
170
|
-
return sortSingleSelect(current, next, {
|
|
172
|
+
return (0, _dtableStore.sortSingleSelect)(current, next, {
|
|
171
173
|
sort_type: sortType,
|
|
172
174
|
option_id_index_map
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
|
-
case CellType.FORMULA:
|
|
176
|
-
case CellType.LINK_FORMULA:
|
|
177
|
+
case _dtableStore.CellType.FORMULA:
|
|
178
|
+
case _dtableStore.CellType.LINK_FORMULA:
|
|
177
179
|
{
|
|
178
180
|
let {
|
|
179
181
|
result_type
|
|
180
182
|
} = data || {};
|
|
181
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
183
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
|
|
182
184
|
if (current) {
|
|
183
185
|
current = current - 0;
|
|
184
186
|
}
|
|
185
187
|
if (next) {
|
|
186
188
|
next = next - 0;
|
|
187
189
|
}
|
|
188
|
-
return sortNumber(current, next, sortType);
|
|
190
|
+
return (0, _dtableStore.sortNumber)(current, next, sortType);
|
|
189
191
|
}
|
|
190
|
-
return sortText(result_type, current, next, sortType);
|
|
192
|
+
return (0, _dtableStore.sortText)(result_type, current, next, sortType);
|
|
191
193
|
}
|
|
192
194
|
default:
|
|
193
195
|
{
|
|
194
|
-
return sortText(current, next, sortType);
|
|
196
|
+
return (0, _dtableStore.sortText)(current, next, sortType);
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
}
|
|
@@ -208,7 +210,7 @@ class StatUtils {
|
|
|
208
210
|
if (!nextVal && nextVal !== 0) {
|
|
209
211
|
return 1;
|
|
210
212
|
}
|
|
211
|
-
if (sortType === DATA_SORT_TYPE.ASCENDING) {
|
|
213
|
+
if (sortType === _constants.DATA_SORT_TYPE.ASCENDING) {
|
|
212
214
|
return currentVal > nextVal ? 1 : -1;
|
|
213
215
|
} else {
|
|
214
216
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -223,9 +225,9 @@ class StatUtils {
|
|
|
223
225
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
224
226
|
let rowsLength = rows.length;
|
|
225
227
|
let total;
|
|
226
|
-
if (summary_type === STATISTICS_COUNT_TYPE.COUNT) {
|
|
228
|
+
if (summary_type === _constants.STATISTICS_COUNT_TYPE.COUNT) {
|
|
227
229
|
total = rowsLength;
|
|
228
|
-
} else if (summary_type === STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
230
|
+
} else if (summary_type === _constants.STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
229
231
|
switch (summary_method) {
|
|
230
232
|
case 'Distinct_values':
|
|
231
233
|
{
|
|
@@ -233,7 +235,7 @@ class StatUtils {
|
|
|
233
235
|
let existMap = {};
|
|
234
236
|
rows.forEach(r => {
|
|
235
237
|
let num;
|
|
236
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
238
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
237
239
|
const formulaRow = formula_rows[r._id] || {};
|
|
238
240
|
num = formulaRow[summary_column_key];
|
|
239
241
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -262,14 +264,14 @@ class StatUtils {
|
|
|
262
264
|
let validNumbersCount = 0;
|
|
263
265
|
rows.forEach(r => {
|
|
264
266
|
let num;
|
|
265
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
267
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
266
268
|
let formulaRow = formula_rows[r._id] || {};
|
|
267
269
|
num = formulaRow[summary_column_key];
|
|
268
270
|
num = Array.isArray(num) ? num[0] : num;
|
|
269
271
|
} else {
|
|
270
272
|
num = r[summary_column_key];
|
|
271
273
|
}
|
|
272
|
-
if (isNumber(num)) {
|
|
274
|
+
if ((0, _dtableStore.isNumber)(num)) {
|
|
273
275
|
validNumbersCount++;
|
|
274
276
|
sum += num;
|
|
275
277
|
}
|
|
@@ -287,7 +289,7 @@ class StatUtils {
|
|
|
287
289
|
if (rowsLength > 0) {
|
|
288
290
|
let result = rows.reduce((current, next) => {
|
|
289
291
|
let currentValue, nextValue;
|
|
290
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
292
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
291
293
|
let currentFormulaRow = formula_rows[current._id];
|
|
292
294
|
let nextFormulaRow = formula_rows[next._id];
|
|
293
295
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -308,7 +310,7 @@ class StatUtils {
|
|
|
308
310
|
return isNextGreater ? next : current;
|
|
309
311
|
}
|
|
310
312
|
});
|
|
311
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
313
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
312
314
|
let formulaRow = formula_rows[result._id];
|
|
313
315
|
total = formulaRow && formulaRow[summary_column_key];
|
|
314
316
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -330,20 +332,20 @@ class StatUtils {
|
|
|
330
332
|
if (!column) {
|
|
331
333
|
return value;
|
|
332
334
|
}
|
|
333
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
335
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Distinct_values) {
|
|
334
336
|
return value;
|
|
335
337
|
}
|
|
336
338
|
const {
|
|
337
339
|
type,
|
|
338
340
|
data
|
|
339
341
|
} = column;
|
|
340
|
-
if (isNumericColumn(column)) {
|
|
341
|
-
return getNumberDisplayString(value, data);
|
|
342
|
+
if ((0, _dtableStore.isNumericColumn)(column)) {
|
|
343
|
+
return (0, _dtableStore.getNumberDisplayString)(value, data);
|
|
342
344
|
}
|
|
343
|
-
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
344
|
-
return getClientFormulaDisplayString(value, data);
|
|
345
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
346
|
+
return (0, _utils.getClientFormulaDisplayString)(value, data);
|
|
345
347
|
}
|
|
346
348
|
return value;
|
|
347
349
|
}
|
|
348
350
|
}
|
|
349
|
-
|
|
351
|
+
var _default = exports.default = StatUtils;
|