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
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,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 _constants = require("../constants");
|
|
10
|
+
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];
|
|
5
11
|
const getValidCollaborators = (collaborators, emails) => {
|
|
6
12
|
if (!Array.isArray(emails)) {
|
|
7
13
|
return [];
|
|
@@ -16,20 +22,20 @@ class StatUtils {
|
|
|
16
22
|
data
|
|
17
23
|
} = column;
|
|
18
24
|
switch (type) {
|
|
19
|
-
case CellType.TEXT:
|
|
25
|
+
case _dtableStore.CellType.TEXT:
|
|
20
26
|
{
|
|
21
27
|
return cellValue || null;
|
|
22
28
|
}
|
|
23
|
-
case CellType.NUMBER:
|
|
29
|
+
case _dtableStore.CellType.NUMBER:
|
|
24
30
|
{
|
|
25
31
|
if (!cellValue && cellValue !== 0) {
|
|
26
32
|
return null;
|
|
27
33
|
}
|
|
28
|
-
const number = getPrecisionNumber(cellValue, data);
|
|
34
|
+
const number = (0, _dtableStore.getPrecisionNumber)(cellValue, data);
|
|
29
35
|
let valueNumber = parseFloat(number);
|
|
30
|
-
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
36
|
+
return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
|
|
31
37
|
}
|
|
32
|
-
case CellType.SINGLE_SELECT:
|
|
38
|
+
case _dtableStore.CellType.SINGLE_SELECT:
|
|
33
39
|
{
|
|
34
40
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
35
41
|
if (isInvalidValue) {
|
|
@@ -37,20 +43,20 @@ class StatUtils {
|
|
|
37
43
|
}
|
|
38
44
|
return cellValue;
|
|
39
45
|
}
|
|
40
|
-
case CellType.DATE:
|
|
41
|
-
case CellType.CTIME:
|
|
42
|
-
case CellType.MTIME:
|
|
46
|
+
case _dtableStore.CellType.DATE:
|
|
47
|
+
case _dtableStore.CellType.CTIME:
|
|
48
|
+
case _dtableStore.CellType.MTIME:
|
|
43
49
|
{
|
|
44
50
|
if (!dateGranularity) {
|
|
45
|
-
return getDateDisplayString(cellValue);
|
|
51
|
+
return (0, _dtableStore.getDateDisplayString)(cellValue);
|
|
46
52
|
}
|
|
47
53
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
48
54
|
// TODO: fix the unknown word 'QUARTAR'
|
|
49
|
-
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
55
|
+
return _dtableStore.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
50
56
|
}
|
|
51
|
-
return DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
57
|
+
return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
52
58
|
}
|
|
53
|
-
case CellType.MULTIPLE_SELECT:
|
|
59
|
+
case _dtableStore.CellType.MULTIPLE_SELECT:
|
|
54
60
|
{
|
|
55
61
|
let options = data && data.options;
|
|
56
62
|
if (!Array.isArray(cellValue)) {
|
|
@@ -58,44 +64,44 @@ class StatUtils {
|
|
|
58
64
|
}
|
|
59
65
|
return cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
60
66
|
}
|
|
61
|
-
case CellType.COLLABORATOR:
|
|
67
|
+
case _dtableStore.CellType.COLLABORATOR:
|
|
62
68
|
{
|
|
63
69
|
return getValidCollaborators(value.collaborators, cellValue);
|
|
64
70
|
}
|
|
65
|
-
case CellType.CREATOR:
|
|
66
|
-
case CellType.LAST_MODIFIER:
|
|
71
|
+
case _dtableStore.CellType.CREATOR:
|
|
72
|
+
case _dtableStore.CellType.LAST_MODIFIER:
|
|
67
73
|
{
|
|
68
74
|
return cellValue ? cellValue : null;
|
|
69
75
|
}
|
|
70
|
-
case CellType.LINK_FORMULA:
|
|
71
|
-
case CellType.FORMULA:
|
|
76
|
+
case _dtableStore.CellType.LINK_FORMULA:
|
|
77
|
+
case _dtableStore.CellType.FORMULA:
|
|
72
78
|
{
|
|
73
79
|
if (!formulaRow) return '';
|
|
74
80
|
let formulaCellValue = formulaRow[key];
|
|
75
81
|
let {
|
|
76
82
|
result_type
|
|
77
83
|
} = data || {};
|
|
78
|
-
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
79
|
-
return getFormulaDisplayString(formulaCellValue, data, {
|
|
84
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
|
|
85
|
+
return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, {
|
|
80
86
|
tables: value.tables
|
|
81
87
|
}) || null;
|
|
82
88
|
}
|
|
83
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
84
|
-
return getPrecisionNumber(formulaCellValue, data);
|
|
89
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
|
|
90
|
+
return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data);
|
|
85
91
|
}
|
|
86
92
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
87
93
|
}
|
|
88
|
-
case CellType.GEOLOCATION:
|
|
94
|
+
case _dtableStore.CellType.GEOLOCATION:
|
|
89
95
|
{
|
|
90
96
|
const {
|
|
91
97
|
geo_format
|
|
92
98
|
} = data || {};
|
|
93
99
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
94
|
-
return getGeolocationDisplayString(cellValue, data);
|
|
100
|
+
return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data);
|
|
95
101
|
}
|
|
96
102
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
97
103
|
}
|
|
98
|
-
case CellType.LINK:
|
|
104
|
+
case _dtableStore.CellType.LINK:
|
|
99
105
|
{
|
|
100
106
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
101
107
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -103,11 +109,11 @@ class StatUtils {
|
|
|
103
109
|
}
|
|
104
110
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
105
111
|
}
|
|
106
|
-
case CellType.CHECKBOX:
|
|
112
|
+
case _dtableStore.CellType.CHECKBOX:
|
|
107
113
|
{
|
|
108
114
|
return String(!!cellValue);
|
|
109
115
|
}
|
|
110
|
-
case CellType.RATE:
|
|
116
|
+
case _dtableStore.CellType.RATE:
|
|
111
117
|
{
|
|
112
118
|
if (!cellValue) return null;
|
|
113
119
|
return cellValue + '';
|
|
@@ -125,7 +131,7 @@ class StatUtils {
|
|
|
125
131
|
} = column;
|
|
126
132
|
let sortType = 'up';
|
|
127
133
|
let option_id_index_map = {};
|
|
128
|
-
if (column_type === CellType.SINGLE_SELECT) {
|
|
134
|
+
if (column_type === _dtableStore.CellType.SINGLE_SELECT) {
|
|
129
135
|
const {
|
|
130
136
|
options
|
|
131
137
|
} = data || {};
|
|
@@ -148,7 +154,7 @@ class StatUtils {
|
|
|
148
154
|
}
|
|
149
155
|
if (SUPPORT_SORT_COLUMNS.includes(column_type)) {
|
|
150
156
|
switch (column_type) {
|
|
151
|
-
case CellType.NUMBER:
|
|
157
|
+
case _dtableStore.CellType.NUMBER:
|
|
152
158
|
{
|
|
153
159
|
if (current) {
|
|
154
160
|
current = current - 0;
|
|
@@ -156,45 +162,46 @@ class StatUtils {
|
|
|
156
162
|
if (next) {
|
|
157
163
|
next = next - 0;
|
|
158
164
|
}
|
|
159
|
-
return sortNumber(current, next, sortType);
|
|
165
|
+
return (0, _dtableStore.sortNumber)(current, next, sortType);
|
|
160
166
|
}
|
|
161
|
-
case CellType.DATE:
|
|
162
|
-
case CellType.CTIME:
|
|
163
|
-
case CellType.MTIME:
|
|
167
|
+
case _dtableStore.CellType.DATE:
|
|
168
|
+
case _dtableStore.CellType.CTIME:
|
|
169
|
+
case _dtableStore.CellType.MTIME:
|
|
164
170
|
{
|
|
165
|
-
return sortDate(current, next, sortType);
|
|
171
|
+
return (0, _dtableStore.sortDate)(current, next, sortType);
|
|
166
172
|
}
|
|
167
|
-
case CellType.SINGLE_SELECT:
|
|
168
|
-
case CellType.MULTIPLE_SELECT:
|
|
173
|
+
case _dtableStore.CellType.SINGLE_SELECT:
|
|
174
|
+
case _dtableStore.CellType.MULTIPLE_SELECT:
|
|
169
175
|
{
|
|
170
|
-
return sortSingleSelect(current, next, {
|
|
176
|
+
return (0, _dtableStore.sortSingleSelect)(current, next, {
|
|
171
177
|
sort_type: sortType,
|
|
172
178
|
option_id_index_map
|
|
173
179
|
});
|
|
174
180
|
}
|
|
175
|
-
case CellType.FORMULA:
|
|
176
|
-
case CellType.LINK_FORMULA:
|
|
181
|
+
case _dtableStore.CellType.FORMULA:
|
|
182
|
+
case _dtableStore.CellType.LINK_FORMULA:
|
|
177
183
|
{
|
|
178
184
|
let {
|
|
179
185
|
result_type
|
|
180
186
|
} = data || {};
|
|
181
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
187
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
|
|
182
188
|
if (current) {
|
|
183
189
|
current = current - 0;
|
|
184
190
|
}
|
|
185
191
|
if (next) {
|
|
186
192
|
next = next - 0;
|
|
187
193
|
}
|
|
188
|
-
return sortNumber(current, next, sortType);
|
|
194
|
+
return (0, _dtableStore.sortNumber)(current, next, sortType);
|
|
189
195
|
}
|
|
190
|
-
return sortText(result_type, current, next, sortType);
|
|
196
|
+
return (0, _dtableStore.sortText)(result_type, current, next, sortType);
|
|
191
197
|
}
|
|
192
198
|
default:
|
|
193
199
|
{
|
|
194
|
-
return sortText(current, next, sortType);
|
|
200
|
+
return (0, _dtableStore.sortText)(current, next, sortType);
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
}
|
|
204
|
+
return 0;
|
|
198
205
|
});
|
|
199
206
|
}
|
|
200
207
|
static sortDataByKey(data, key, sortType) {
|
|
@@ -207,7 +214,7 @@ class StatUtils {
|
|
|
207
214
|
if (!nextVal && nextVal !== 0) {
|
|
208
215
|
return 1;
|
|
209
216
|
}
|
|
210
|
-
if (sortType === DATA_SORT_TYPE.ASCENDING) {
|
|
217
|
+
if (sortType === _constants.DATA_SORT_TYPE.ASCENDING) {
|
|
211
218
|
return currentVal > nextVal ? 1 : -1;
|
|
212
219
|
} else {
|
|
213
220
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -222,9 +229,9 @@ class StatUtils {
|
|
|
222
229
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
223
230
|
let rowsLength = rows.length;
|
|
224
231
|
let total;
|
|
225
|
-
if (summary_type === STATISTICS_COUNT_TYPE.COUNT) {
|
|
232
|
+
if (summary_type === _constants.STATISTICS_COUNT_TYPE.COUNT) {
|
|
226
233
|
total = rowsLength;
|
|
227
|
-
} else if (summary_type === STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
234
|
+
} else if (summary_type === _constants.STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
228
235
|
switch (summary_method) {
|
|
229
236
|
case 'Distinct_values':
|
|
230
237
|
{
|
|
@@ -232,7 +239,7 @@ class StatUtils {
|
|
|
232
239
|
let existMap = {};
|
|
233
240
|
rows.forEach(r => {
|
|
234
241
|
let num;
|
|
235
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
242
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
236
243
|
const formulaRow = formula_rows[r._id] || {};
|
|
237
244
|
num = formulaRow[summary_column_key];
|
|
238
245
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -261,14 +268,14 @@ class StatUtils {
|
|
|
261
268
|
let validNumbersCount = 0;
|
|
262
269
|
rows.forEach(r => {
|
|
263
270
|
let num;
|
|
264
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
271
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
265
272
|
let formulaRow = formula_rows[r._id] || {};
|
|
266
273
|
num = formulaRow[summary_column_key];
|
|
267
274
|
num = Array.isArray(num) ? num[0] : num;
|
|
268
275
|
} else {
|
|
269
276
|
num = r[summary_column_key];
|
|
270
277
|
}
|
|
271
|
-
if (isNumber(num)) {
|
|
278
|
+
if ((0, _dtableStore.isNumber)(num)) {
|
|
272
279
|
validNumbersCount++;
|
|
273
280
|
sum += num;
|
|
274
281
|
}
|
|
@@ -286,7 +293,7 @@ class StatUtils {
|
|
|
286
293
|
if (rowsLength > 0) {
|
|
287
294
|
let result = rows.reduce((current, next) => {
|
|
288
295
|
let currentValue, nextValue;
|
|
289
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
296
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
290
297
|
let currentFormulaRow = formula_rows[current._id];
|
|
291
298
|
let nextFormulaRow = formula_rows[next._id];
|
|
292
299
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -307,7 +314,7 @@ class StatUtils {
|
|
|
307
314
|
return isNextGreater ? next : current;
|
|
308
315
|
}
|
|
309
316
|
});
|
|
310
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
317
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
311
318
|
let formulaRow = formula_rows[result._id];
|
|
312
319
|
total = formulaRow && formulaRow[summary_column_key];
|
|
313
320
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -329,20 +336,20 @@ class StatUtils {
|
|
|
329
336
|
if (!column) {
|
|
330
337
|
return value;
|
|
331
338
|
}
|
|
332
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
339
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Distinct_values) {
|
|
333
340
|
return value;
|
|
334
341
|
}
|
|
335
342
|
const {
|
|
336
343
|
type,
|
|
337
344
|
data
|
|
338
345
|
} = column;
|
|
339
|
-
if (isNumericColumn(column)) {
|
|
340
|
-
return getNumberDisplayString(value, data);
|
|
346
|
+
if ((0, _dtableStore.isNumericColumn)(column)) {
|
|
347
|
+
return (0, _dtableStore.getNumberDisplayString)(value, data);
|
|
341
348
|
}
|
|
342
|
-
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
343
|
-
return getClientFormulaDisplayString(value, data);
|
|
349
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
350
|
+
return (0, _utils.getClientFormulaDisplayString)(value, data);
|
|
344
351
|
}
|
|
345
352
|
return value;
|
|
346
353
|
}
|
|
347
354
|
}
|
|
348
|
-
|
|
355
|
+
var _default = exports.default = StatUtils;
|