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