dtable-statistic 4.3.6 → 4.3.7
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/calculator/base-calculator.js +16 -5
- package/es/calculator/basic-chart-calculator.js +17 -31
- package/es/calculator/combination-calculator.js +19 -30
- package/es/calculator/compare-bar-calculator.js +9 -20
- package/es/calculator/completeness-calculator.js +10 -24
- package/es/calculator/dashboard-calculator.js +6 -20
- package/es/calculator/heat-map-calculator.js +6 -20
- package/es/calculator/horizontal-bar-calculator.js +2 -13
- package/es/calculator/index.js +2 -0
- package/es/calculator/map-calculator.js +7 -21
- package/es/calculator/mirror-calculator.js +8 -22
- package/es/calculator/number-card-calculator.js +4 -18
- package/es/calculator/pivot-table-calculator.js +40 -54
- package/es/calculator/scatter-calculator.js +6 -20
- package/es/calculator/trend-calculator.js +6 -20
- package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
- package/es/calculator/workers/calculator.worker.js +5 -2
- package/es/calculator/workers/card-calculator-worker.js +13 -9
- package/es/calculator/workers/combination-calculator-worker.js +20 -16
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
- package/es/calculator/workers/completeness-calculator-worker.js +21 -17
- package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
- package/es/calculator/workers/mirror-calculator-worker.js +14 -10
- package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
- package/es/calculator/workers/scatter-calculator-worker.js +15 -11
- package/es/calculator/workers/trend-calculator-worker.js +14 -10
- package/es/calculator/world-map-calculator.js +6 -20
- package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
- package/es/components/dialog/statistic-record-dialog/index.js +21 -11
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
- package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
- package/es/components/popover/color-rules-popover.js +2 -2
- package/es/components/toast/alert.js +2 -0
- package/es/components/toast/toastManager.js +1 -0
- package/es/constants/color-rules.js +3 -3
- package/es/constants/index.js +9 -9
- package/es/dashboard.js +7 -13
- package/es/desktop-dashboard.js +1 -1
- package/es/locale/lang/de.js +10 -10
- package/es/locale/lang/en.js +8 -8
- package/es/locale/lang/fr.js +10 -10
- package/es/locale/lang/zh_CN.js +8 -8
- package/es/model/basic-number-card.js +3 -3
- package/es/model/compare-bar.js +2 -2
- package/es/model/generic-model.js +11 -11
- package/es/model/heat-map.js +2 -2
- package/es/model/horizontal-bar.js +2 -2
- package/es/model/index.js +3 -2
- package/es/model/map.js +3 -3
- package/es/model/mirror.js +2 -2
- package/es/model/trend.js +2 -2
- package/es/model/world-map.js +3 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
- package/es/stat-view/area-chart.js +4 -4
- package/es/stat-view/bar-chart.js +4 -4
- package/es/stat-view/base-chart.js +2 -2
- package/es/stat-view/basic-number-card.js +2 -2
- package/es/stat-view/combination-chart.js +9 -9
- package/es/stat-view/compare-chart.js +4 -4
- package/es/stat-view/completeness-chart.js +3 -3
- package/es/stat-view/custom-bar.js +2 -2
- package/es/stat-view/heat-map.js +2 -2
- package/es/stat-view/horizontal-bar-chart.js +4 -4
- package/es/stat-view/line-chart.js +4 -4
- package/es/stat-view/map.js +3 -3
- package/es/stat-view/mirror.js +2 -2
- package/es/stat-view/pivot-table/index.js +6 -6
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
- package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
- package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
- package/es/stat-view/ring-chart.js +2 -2
- package/es/stat-view/scatter-chart.js +5 -5
- package/es/stat-view/treemap-chart.js +3 -2
- package/es/stat-view/trend-chart.js +2 -2
- package/es/stat-view/world-map.js +3 -3
- package/es/utils/cell-format.js +14 -15
- package/es/utils/cell-value.js +3 -3
- package/es/utils/color-utils.js +3 -3
- package/es/utils/column-utils.js +10 -10
- package/es/utils/column.js +2 -2
- package/es/utils/common-utils.js +10 -8
- package/es/utils/export-table-utils.js +38 -38
- package/es/utils/pivot-table.js +3 -3
- package/es/utils/row-utils.js +17 -17
- package/es/utils/search.js +14 -14
- package/es/utils/sql-utils.js +23 -20
- package/es/utils/stat-utils.js +52 -52
- package/es/utils/trend-utils.js +1 -0
- package/package.json +3 -2
package/es/utils/row-utils.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getCellValue = getCellValue;
|
|
7
7
|
exports.isValidRow = exports.isEmptyGeolocationCell = exports.getFormattedLabel = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
9
|
var _utils = require("../utils");
|
|
10
10
|
const isEmptyGeolocationCell = (cellValue, format) => {
|
|
11
11
|
if (!cellValue) return null;
|
|
@@ -23,15 +23,15 @@ const isValidRow = (row, formulaRow, column, includeEmpty) => {
|
|
|
23
23
|
type: columnType,
|
|
24
24
|
key: columnKey
|
|
25
25
|
} = column;
|
|
26
|
-
if (includeEmpty || columnType ===
|
|
27
|
-
if (columnType ===
|
|
26
|
+
if (includeEmpty || columnType === _dtableUtils.CellType.CHECKBOX) return true;
|
|
27
|
+
if (columnType === _dtableUtils.CellType.GEOLOCATION) {
|
|
28
28
|
const {
|
|
29
29
|
geo_format
|
|
30
30
|
} = column.data;
|
|
31
31
|
return isEmptyGeolocationCell(row[columnKey], geo_format);
|
|
32
32
|
}
|
|
33
33
|
let cellValue = row[columnKey];
|
|
34
|
-
if (
|
|
34
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableUtils.CellType.LINK) {
|
|
35
35
|
cellValue = formulaRow ? formulaRow[columnKey] : null;
|
|
36
36
|
}
|
|
37
37
|
return cellValue || cellValue === 0;
|
|
@@ -42,7 +42,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
42
42
|
type: columnType,
|
|
43
43
|
data: columnData
|
|
44
44
|
} = column;
|
|
45
|
-
if (columnType ===
|
|
45
|
+
if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
46
46
|
let options = columnData ? columnData.options : [];
|
|
47
47
|
let selectedOption = options.find(o => {
|
|
48
48
|
let id = name;
|
|
@@ -57,7 +57,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
57
57
|
if (selectedOption) {
|
|
58
58
|
return optionName;
|
|
59
59
|
}
|
|
60
|
-
} else if (columnType ===
|
|
60
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
61
61
|
let collaborator = collaborators.find(item => {
|
|
62
62
|
let email = name;
|
|
63
63
|
if (Array.isArray(name)) {
|
|
@@ -68,7 +68,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
68
68
|
if (collaborator) {
|
|
69
69
|
return collaborator.name;
|
|
70
70
|
}
|
|
71
|
-
} else if (columnType ===
|
|
71
|
+
} else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
|
|
72
72
|
if (name === 'anonymous') {
|
|
73
73
|
return name;
|
|
74
74
|
} else {
|
|
@@ -77,25 +77,25 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
77
77
|
return collaborator.name;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
} else if (columnType ===
|
|
80
|
+
} else if (columnType === _dtableUtils.CellType.LINK) {
|
|
81
81
|
return (0, _utils.getClientFormulaDisplayString)(Array.isArray(name) ? name : [name], columnData, {
|
|
82
82
|
collaborators
|
|
83
83
|
});
|
|
84
|
-
} else if (columnType ===
|
|
84
|
+
} else if (columnType === _dtableUtils.CellType.CHECKBOX) {
|
|
85
85
|
return name === 'true' ? 'Checked' : 'Unchecked';
|
|
86
|
-
} else if (
|
|
86
|
+
} else if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
87
87
|
const {
|
|
88
88
|
result_type,
|
|
89
89
|
array_type
|
|
90
90
|
} = columnData || {};
|
|
91
|
-
if (!name && !(0,
|
|
92
|
-
if (result_type ===
|
|
91
|
+
if (!name && !(0, _dtableUtils.isNumber)(name)) return '';
|
|
92
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
93
93
|
const valueNumber = parseFloat(name);
|
|
94
|
-
return (0,
|
|
94
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : name;
|
|
95
95
|
}
|
|
96
|
-
if (result_type ===
|
|
97
|
-
if (
|
|
98
|
-
if ([
|
|
96
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
97
|
+
if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
98
|
+
if ([_dtableUtils.CellType.CREATOR, _dtableUtils.CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
|
|
99
99
|
return name;
|
|
100
100
|
}
|
|
101
101
|
const collaborator = collaborators.find(item => {
|
|
@@ -123,7 +123,7 @@ function getCellValue(row, formulaRow, column) {
|
|
|
123
123
|
type,
|
|
124
124
|
key
|
|
125
125
|
} = column;
|
|
126
|
-
if (
|
|
126
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
127
127
|
const cellValue = formulaRow && formulaRow[key];
|
|
128
128
|
if (Array.isArray(cellValue)) {
|
|
129
129
|
return cellValue[0];
|
package/es/utils/search.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.searchRows = void 0;
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
var
|
|
9
|
+
var _dtableUtils = require("dtable-utils");
|
|
10
10
|
var _column = require("./column");
|
|
11
|
-
const SUPPORT_SEARCH_COLUMN_TYPES = [
|
|
11
|
+
const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableUtils.CellType.DATE, _dtableUtils.CellType.TEXT, _dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.URL, _dtableUtils.CellType.EMAIL, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.LAST_MODIFIER, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.LINK, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.AUTO_NUMBER, _dtableUtils.CellType.GEOLOCATION, _dtableUtils.CellType.DURATION];
|
|
12
12
|
const searchRows = (rows, columns, val, processRow) => {
|
|
13
13
|
let dtableCollaborators = window.app.collaboratorsCache || [];
|
|
14
14
|
let collaborators = window.app.state.collaborators;
|
|
@@ -25,20 +25,20 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
25
25
|
const cellValue = row[columnKey];
|
|
26
26
|
if (cellValue) {
|
|
27
27
|
let text;
|
|
28
|
-
if (columnType ===
|
|
28
|
+
if (columnType === _dtableUtils.CellType.LONG_TEXT) {
|
|
29
29
|
text = cellValue.text;
|
|
30
|
-
} else if (columnType ===
|
|
31
|
-
text = (0,
|
|
32
|
-
} else if (columnType ===
|
|
30
|
+
} else if (columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.DURATION) {
|
|
31
|
+
text = (0, _dtableUtils.getNumberDisplayString)(cellValue, column.data);
|
|
32
|
+
} else if (columnType === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
33
33
|
const options = (0, _column.getSelectColumnOptions)(column);
|
|
34
34
|
const option = options.find(option => option.id === cellValue);
|
|
35
35
|
text = option ? option.name : '';
|
|
36
|
-
} else if (columnType ===
|
|
36
|
+
} else if (columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
37
37
|
const options = (0, _column.getSelectColumnOptions)(column);
|
|
38
|
-
text = (0,
|
|
39
|
-
} else if (columnType ===
|
|
40
|
-
text = (0,
|
|
41
|
-
} else if (columnType ===
|
|
38
|
+
text = (0, _dtableUtils.getMultipleOptionName)(options, cellValue);
|
|
39
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
40
|
+
text = (0, _dtableUtils.getCollaboratorsName)(collaborators, cellValue);
|
|
41
|
+
} else if (columnType === _dtableUtils.CellType.LAST_MODIFIER || columnType === _dtableUtils.CellType.CREATOR) {
|
|
42
42
|
if (cellValue === 'anonymous') {
|
|
43
43
|
text = cellValue;
|
|
44
44
|
} else {
|
|
@@ -50,9 +50,9 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
50
50
|
text = collaborator.name;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
} else if (columnType ===
|
|
54
|
-
text = (0,
|
|
55
|
-
} else if (columnType ===
|
|
53
|
+
} else if (columnType === _dtableUtils.CellType.GEOLOCATION) {
|
|
54
|
+
text = (0, _dtableUtils.getGeolocationDisplayString)(cellValue, column.data);
|
|
55
|
+
} else if (columnType === _dtableUtils.CellType.CTIME || columnType === _dtableUtils.CellType.MTIME) {
|
|
56
56
|
text = (0, _dayjs.default)(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
|
57
57
|
} else {
|
|
58
58
|
text = cellValue;
|
package/es/utils/sql-utils.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getSqlString = exports.getSqlOrder = exports.getSqlGroup = exports.getPieChartSqlGroupName = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
const getSqlOrder = (sortType, groupName) => {
|
|
10
10
|
if (!sortType) {
|
|
@@ -33,7 +33,7 @@ const getSqlGroup = (granularity, column) => {
|
|
|
33
33
|
return "CONCATENATE(year(".concat(columnName, "), \"-Q\", quarter(").concat(columnName, "))");
|
|
34
34
|
}
|
|
35
35
|
return "YEAR(".concat(columnName, ")");
|
|
36
|
-
} else if (type ===
|
|
36
|
+
} else if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
37
37
|
if (granularity === _constants.STATISTICS_COUNT_TYPE.PROVINCE) {
|
|
38
38
|
return "PROVINCE(".concat(columnName, ")");
|
|
39
39
|
}
|
|
@@ -70,7 +70,10 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
70
70
|
isColumn,
|
|
71
71
|
isCurrentView,
|
|
72
72
|
isRow,
|
|
73
|
-
getTableById
|
|
73
|
+
getTableById,
|
|
74
|
+
username,
|
|
75
|
+
userId,
|
|
76
|
+
userDepartmentIdsMap
|
|
74
77
|
} = _ref;
|
|
75
78
|
const {
|
|
76
79
|
table_id,
|
|
@@ -80,7 +83,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
80
83
|
type
|
|
81
84
|
} = statItem;
|
|
82
85
|
const selectedTable = getTableById(table_id);
|
|
83
|
-
const selectedView =
|
|
86
|
+
const selectedView = (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
|
|
84
87
|
const {
|
|
85
88
|
groupName,
|
|
86
89
|
selectedColumn,
|
|
@@ -89,7 +92,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
89
92
|
} = getDatabaseGroupName(statItem, selectedTable, {
|
|
90
93
|
isCurrentView
|
|
91
94
|
});
|
|
92
|
-
const sqlCondition = (0,
|
|
95
|
+
const sqlCondition = (0, _dtableUtils.filter2SqlCondition)(selectedTable, selectedView, username, userId, userDepartmentIdsMap);
|
|
93
96
|
const isGroup = column_groupby_column_key && !column_groupby_multiple_numeric_column;
|
|
94
97
|
const {
|
|
95
98
|
name,
|
|
@@ -143,7 +146,7 @@ const getSqlGroupName = (name, original_name, column) => {
|
|
|
143
146
|
const {
|
|
144
147
|
type
|
|
145
148
|
} = column || {};
|
|
146
|
-
if (type ===
|
|
149
|
+
if (type === _dtableUtils.CellType.SINGLE_SELECT || type === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
147
150
|
return "'".concat(name, "'");
|
|
148
151
|
}
|
|
149
152
|
const newName = original_name ? original_name : name;
|
|
@@ -161,7 +164,7 @@ const getGroupName = (selectedColumn, _ref2) => {
|
|
|
161
164
|
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(selectedColumn.type);
|
|
162
165
|
if (isTimeColumn) {
|
|
163
166
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
164
|
-
} else if (selectedColumn.type ===
|
|
167
|
+
} else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
|
|
165
168
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
166
169
|
}
|
|
167
170
|
return groupName;
|
|
@@ -209,13 +212,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
209
212
|
groupby_geolocation_granularity = statItem.x_axis_geolocation_granularity;
|
|
210
213
|
}
|
|
211
214
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
212
|
-
columnSelectedColumn =
|
|
215
|
+
columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
|
|
213
216
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
214
217
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
215
218
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
|
-
selectedColumn =
|
|
221
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
|
|
219
222
|
groupName = getGroupName(selectedColumn, {
|
|
220
223
|
groupby_date_granularity,
|
|
221
224
|
groupby_geolocation_granularity
|
|
@@ -229,7 +232,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
229
232
|
geolocation_granularity,
|
|
230
233
|
geo_column
|
|
231
234
|
} = statItem;
|
|
232
|
-
selectedColumn =
|
|
235
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, geo_column);
|
|
233
236
|
groupName = getSqlGroup(geolocation_granularity, selectedColumn);
|
|
234
237
|
break;
|
|
235
238
|
}
|
|
@@ -240,7 +243,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
240
243
|
const {
|
|
241
244
|
column
|
|
242
245
|
} = statItem;
|
|
243
|
-
selectedColumn =
|
|
246
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column);
|
|
244
247
|
groupName = selectedColumn.name;
|
|
245
248
|
break;
|
|
246
249
|
}
|
|
@@ -249,7 +252,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
249
252
|
const {
|
|
250
253
|
time_column
|
|
251
254
|
} = statItem;
|
|
252
|
-
selectedColumn =
|
|
255
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, time_column);
|
|
253
256
|
groupName = "ISODATE(".concat(selectedColumn.name, ")");
|
|
254
257
|
break;
|
|
255
258
|
}
|
|
@@ -258,7 +261,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
258
261
|
const {
|
|
259
262
|
group_column
|
|
260
263
|
} = statItem;
|
|
261
|
-
selectedColumn =
|
|
264
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, group_column);
|
|
262
265
|
groupName = selectedColumn.name;
|
|
263
266
|
break;
|
|
264
267
|
}
|
|
@@ -273,7 +276,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
273
276
|
x_axis_column_key,
|
|
274
277
|
x_axis_date_granularity
|
|
275
278
|
} = statItem;
|
|
276
|
-
selectedColumn =
|
|
279
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
|
|
277
280
|
groupName = getSqlGroup(x_axis_date_granularity, selectedColumn);
|
|
278
281
|
break;
|
|
279
282
|
}
|
|
@@ -284,12 +287,12 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
284
287
|
x_axis_date_granularity: groupby_date_granularity,
|
|
285
288
|
x_axis_geolocation_granularity: groupby_geolocation_granularity
|
|
286
289
|
} = statItem;
|
|
287
|
-
selectedColumn =
|
|
290
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
|
|
288
291
|
if (!selectedColumn) return [];
|
|
289
292
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
290
293
|
if (_constants.TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
291
294
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
292
|
-
} else if (selectedColumn.type ===
|
|
295
|
+
} else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
|
|
293
296
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
294
297
|
}
|
|
295
298
|
break;
|
|
@@ -300,7 +303,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
300
303
|
date_column,
|
|
301
304
|
date_granularity
|
|
302
305
|
} = statItem;
|
|
303
|
-
selectedColumn =
|
|
306
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, date_column);
|
|
304
307
|
groupName = getSqlGroup(date_granularity, selectedColumn);
|
|
305
308
|
break;
|
|
306
309
|
}
|
|
@@ -310,7 +313,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
310
313
|
const {
|
|
311
314
|
name_column
|
|
312
315
|
} = statItem;
|
|
313
|
-
selectedColumn =
|
|
316
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, name_column);
|
|
314
317
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
315
318
|
break;
|
|
316
319
|
}
|
|
@@ -331,13 +334,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
331
334
|
column_groupby_multiple_numeric_column
|
|
332
335
|
} = statItem;
|
|
333
336
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
334
|
-
columnSelectedColumn =
|
|
337
|
+
columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
|
|
335
338
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
336
339
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
337
340
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
338
341
|
});
|
|
339
342
|
}
|
|
340
|
-
selectedColumn =
|
|
343
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
|
|
341
344
|
groupName = getGroupName(selectedColumn, {
|
|
342
345
|
groupby_date_granularity,
|
|
343
346
|
groupby_geolocation_granularity
|
package/es/utils/stat-utils.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _utils = require("../utils");
|
|
9
9
|
var _collaborator = require("./collaborator");
|
|
10
10
|
var _constants = require("../constants");
|
|
11
|
-
const SUPPORT_SORT_COLUMNS = [
|
|
11
|
+
const SUPPORT_SORT_COLUMNS = [_dtableUtils.CellType.TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.DATE, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.RATE];
|
|
12
12
|
class StatUtils {
|
|
13
13
|
static getGroupLabel(cellValue, formulaRow, column, dateGranularity, geoGranularity, value) {
|
|
14
14
|
let {
|
|
@@ -17,20 +17,20 @@ class StatUtils {
|
|
|
17
17
|
data
|
|
18
18
|
} = column;
|
|
19
19
|
switch (type) {
|
|
20
|
-
case
|
|
20
|
+
case _dtableUtils.CellType.TEXT:
|
|
21
21
|
{
|
|
22
22
|
return cellValue || null;
|
|
23
23
|
}
|
|
24
|
-
case
|
|
24
|
+
case _dtableUtils.CellType.NUMBER:
|
|
25
25
|
{
|
|
26
26
|
if (!cellValue && cellValue !== 0) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
const number = (0,
|
|
29
|
+
const number = (0, _dtableUtils.getPrecisionNumber)(cellValue, data);
|
|
30
30
|
let valueNumber = parseFloat(number);
|
|
31
|
-
return (0,
|
|
31
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
|
|
32
32
|
}
|
|
33
|
-
case
|
|
33
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
34
34
|
{
|
|
35
35
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
36
36
|
if (isInvalidValue) {
|
|
@@ -38,20 +38,20 @@ class StatUtils {
|
|
|
38
38
|
}
|
|
39
39
|
return cellValue;
|
|
40
40
|
}
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
41
|
+
case _dtableUtils.CellType.DATE:
|
|
42
|
+
case _dtableUtils.CellType.CTIME:
|
|
43
|
+
case _dtableUtils.CellType.MTIME:
|
|
44
44
|
{
|
|
45
45
|
if (!dateGranularity) {
|
|
46
|
-
return (0,
|
|
46
|
+
return (0, _dtableUtils.getDateDisplayString)(cellValue);
|
|
47
47
|
}
|
|
48
48
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
49
49
|
// TODO: fix the unknown word 'QUARTAR'
|
|
50
|
-
return
|
|
50
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
53
53
|
}
|
|
54
|
-
case
|
|
54
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
55
55
|
{
|
|
56
56
|
let options = data && data.options;
|
|
57
57
|
if (!Array.isArray(cellValue)) {
|
|
@@ -59,45 +59,45 @@ class StatUtils {
|
|
|
59
59
|
}
|
|
60
60
|
return cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
61
61
|
}
|
|
62
|
-
case
|
|
62
|
+
case _dtableUtils.CellType.COLLABORATOR:
|
|
63
63
|
{
|
|
64
64
|
if (!Array.isArray(cellValue)) return [];
|
|
65
65
|
return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
|
|
66
66
|
}
|
|
67
|
-
case
|
|
68
|
-
case
|
|
67
|
+
case _dtableUtils.CellType.CREATOR:
|
|
68
|
+
case _dtableUtils.CellType.LAST_MODIFIER:
|
|
69
69
|
{
|
|
70
70
|
return cellValue ? cellValue : null;
|
|
71
71
|
}
|
|
72
|
-
case
|
|
73
|
-
case
|
|
72
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
73
|
+
case _dtableUtils.CellType.FORMULA:
|
|
74
74
|
{
|
|
75
75
|
if (!formulaRow) return '';
|
|
76
76
|
let formulaCellValue = formulaRow[key];
|
|
77
77
|
let {
|
|
78
78
|
result_type
|
|
79
79
|
} = data || {};
|
|
80
|
-
if (result_type ===
|
|
81
|
-
return (0,
|
|
80
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
81
|
+
return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
|
|
82
82
|
tables: value.tables
|
|
83
83
|
}) || null;
|
|
84
84
|
}
|
|
85
|
-
if (result_type ===
|
|
86
|
-
return (0,
|
|
85
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
86
|
+
return (0, _dtableUtils.getPrecisionNumber)(formulaCellValue, data);
|
|
87
87
|
}
|
|
88
88
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
89
89
|
}
|
|
90
|
-
case
|
|
90
|
+
case _dtableUtils.CellType.GEOLOCATION:
|
|
91
91
|
{
|
|
92
92
|
const {
|
|
93
93
|
geo_format
|
|
94
94
|
} = data || {};
|
|
95
95
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
96
|
-
return (0,
|
|
96
|
+
return (0, _dtableUtils.getGeolocationDisplayString)(cellValue, data);
|
|
97
97
|
}
|
|
98
98
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
99
99
|
}
|
|
100
|
-
case
|
|
100
|
+
case _dtableUtils.CellType.LINK:
|
|
101
101
|
{
|
|
102
102
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
103
103
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -105,11 +105,11 @@ class StatUtils {
|
|
|
105
105
|
}
|
|
106
106
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
107
107
|
}
|
|
108
|
-
case
|
|
108
|
+
case _dtableUtils.CellType.CHECKBOX:
|
|
109
109
|
{
|
|
110
110
|
return String(!!cellValue);
|
|
111
111
|
}
|
|
112
|
-
case
|
|
112
|
+
case _dtableUtils.CellType.RATE:
|
|
113
113
|
{
|
|
114
114
|
if (!cellValue) return null;
|
|
115
115
|
return cellValue + '';
|
|
@@ -127,7 +127,7 @@ class StatUtils {
|
|
|
127
127
|
} = column;
|
|
128
128
|
let sortType = 'up';
|
|
129
129
|
let option_id_index_map = {};
|
|
130
|
-
if (column_type ===
|
|
130
|
+
if (column_type === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
131
131
|
const {
|
|
132
132
|
options
|
|
133
133
|
} = data || {};
|
|
@@ -150,7 +150,7 @@ class StatUtils {
|
|
|
150
150
|
}
|
|
151
151
|
if (SUPPORT_SORT_COLUMNS.includes(column_type)) {
|
|
152
152
|
switch (column_type) {
|
|
153
|
-
case
|
|
153
|
+
case _dtableUtils.CellType.NUMBER:
|
|
154
154
|
{
|
|
155
155
|
if (current) {
|
|
156
156
|
current = current - 0;
|
|
@@ -158,42 +158,42 @@ class StatUtils {
|
|
|
158
158
|
if (next) {
|
|
159
159
|
next = next - 0;
|
|
160
160
|
}
|
|
161
|
-
return (0,
|
|
161
|
+
return (0, _dtableUtils.sortNumber)(current, next, sortType);
|
|
162
162
|
}
|
|
163
|
-
case
|
|
164
|
-
case
|
|
165
|
-
case
|
|
163
|
+
case _dtableUtils.CellType.DATE:
|
|
164
|
+
case _dtableUtils.CellType.CTIME:
|
|
165
|
+
case _dtableUtils.CellType.MTIME:
|
|
166
166
|
{
|
|
167
|
-
return (0,
|
|
167
|
+
return (0, _dtableUtils.sortDate)(current, next, sortType);
|
|
168
168
|
}
|
|
169
|
-
case
|
|
170
|
-
case
|
|
169
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
170
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
171
171
|
{
|
|
172
|
-
return (0,
|
|
172
|
+
return (0, _dtableUtils.sortSingleSelect)(current, next, {
|
|
173
173
|
sort_type: sortType,
|
|
174
174
|
option_id_index_map
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
case
|
|
178
|
-
case
|
|
177
|
+
case _dtableUtils.CellType.FORMULA:
|
|
178
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
179
179
|
{
|
|
180
180
|
let {
|
|
181
181
|
result_type
|
|
182
182
|
} = data || {};
|
|
183
|
-
if (result_type ===
|
|
183
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
184
184
|
if (current) {
|
|
185
185
|
current = current - 0;
|
|
186
186
|
}
|
|
187
187
|
if (next) {
|
|
188
188
|
next = next - 0;
|
|
189
189
|
}
|
|
190
|
-
return (0,
|
|
190
|
+
return (0, _dtableUtils.sortNumber)(current, next, sortType);
|
|
191
191
|
}
|
|
192
|
-
return (0,
|
|
192
|
+
return (0, _dtableUtils.sortText)(result_type, current, next, sortType);
|
|
193
193
|
}
|
|
194
194
|
default:
|
|
195
195
|
{
|
|
196
|
-
return (0,
|
|
196
|
+
return (0, _dtableUtils.sortText)(current, next, sortType);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -235,7 +235,7 @@ class StatUtils {
|
|
|
235
235
|
let existMap = {};
|
|
236
236
|
rows.forEach(r => {
|
|
237
237
|
let num;
|
|
238
|
-
if (
|
|
238
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
239
239
|
const formulaRow = formula_rows[r._id] || {};
|
|
240
240
|
num = formulaRow[summary_column_key];
|
|
241
241
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -264,14 +264,14 @@ class StatUtils {
|
|
|
264
264
|
let validNumbersCount = 0;
|
|
265
265
|
rows.forEach(r => {
|
|
266
266
|
let num;
|
|
267
|
-
if (
|
|
267
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
268
268
|
let formulaRow = formula_rows[r._id] || {};
|
|
269
269
|
num = formulaRow[summary_column_key];
|
|
270
270
|
num = Array.isArray(num) ? num[0] : num;
|
|
271
271
|
} else {
|
|
272
272
|
num = r[summary_column_key];
|
|
273
273
|
}
|
|
274
|
-
if ((0,
|
|
274
|
+
if ((0, _dtableUtils.isNumber)(num)) {
|
|
275
275
|
validNumbersCount++;
|
|
276
276
|
sum += num;
|
|
277
277
|
}
|
|
@@ -289,7 +289,7 @@ class StatUtils {
|
|
|
289
289
|
if (rowsLength > 0) {
|
|
290
290
|
let result = rows.reduce((current, next) => {
|
|
291
291
|
let currentValue, nextValue;
|
|
292
|
-
if (
|
|
292
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
293
293
|
let currentFormulaRow = formula_rows[current._id];
|
|
294
294
|
let nextFormulaRow = formula_rows[next._id];
|
|
295
295
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -310,7 +310,7 @@ class StatUtils {
|
|
|
310
310
|
return isNextGreater ? next : current;
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
|
-
if (
|
|
313
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
314
314
|
let formulaRow = formula_rows[result._id];
|
|
315
315
|
total = formulaRow && formulaRow[summary_column_key];
|
|
316
316
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -339,10 +339,10 @@ class StatUtils {
|
|
|
339
339
|
type,
|
|
340
340
|
data
|
|
341
341
|
} = column;
|
|
342
|
-
if ((0,
|
|
343
|
-
return (0,
|
|
342
|
+
if ((0, _dtableUtils.isNumericColumn)(column)) {
|
|
343
|
+
return (0, _dtableUtils.getNumberDisplayString)(value, data);
|
|
344
344
|
}
|
|
345
|
-
if (
|
|
345
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
346
346
|
return (0, _utils.getClientFormulaDisplayString)(value, data);
|
|
347
347
|
}
|
|
348
348
|
return value;
|
package/es/utils/trend-utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"description": "statistics",
|
|
5
5
|
"main": "dist/dtable-statistic.js",
|
|
6
6
|
"author": "seafile",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@seafile/seafile-calendar": "0.0.24",
|
|
13
13
|
"comlink": "^4.3.1",
|
|
14
14
|
"dayjs": "1.10.7",
|
|
15
|
-
"dtable-
|
|
15
|
+
"dtable-utils": "4.3.3",
|
|
16
16
|
"dtable-web-api": "4.3.5",
|
|
17
17
|
"glamor": "^2.20.40",
|
|
18
18
|
"html2canvas": "^1.4.1",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
56
56
|
"dotenv": "^10.0.0",
|
|
57
57
|
"dotenv-expand": "^5.1.0",
|
|
58
|
+
"dtable-store": "4.3.6",
|
|
58
59
|
"eslint": "^8.3.0",
|
|
59
60
|
"eslint-config-react-app": "^7.0.1",
|
|
60
61
|
"eslint-webpack-plugin": "^3.1.1",
|