dtable-statistic 4.3.4 → 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +108 -101
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +21 -14
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +49 -41
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +34 -27
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +41 -34
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +45 -37
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +55 -47
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +19 -11
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +53 -45
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +28 -20
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +55 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +19 -11
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +28 -20
- package/es/stat-list/index.js +35 -27
- package/es/stat-view/area-chart.js +50 -43
- package/es/stat-view/bar-chart.js +54 -47
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +56 -49
- package/es/stat-view/compare-chart.js +46 -39
- package/es/stat-view/completeness-chart.js +35 -28
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +58 -51
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +46 -39
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +72 -70
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +45 -38
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +44 -37
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +34 -26
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +65 -41
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +33 -23
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +69 -67
- package/es/utils/trend-utils.js +40 -32
- package/package.json +3 -3
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _dtableStore = require("dtable-store");
|
|
9
|
+
var _baseCalculator = _interopRequireDefault(require("./base-calculator"));
|
|
10
|
+
var _commonUtils = require("../utils/common-utils");
|
|
11
|
+
var _sqlUtils = require("../utils/sql-utils");
|
|
12
|
+
var _trendUtils = require("../utils/trend-utils");
|
|
13
|
+
var _constants = require("../constants");
|
|
14
|
+
class TrendCalculator extends _baseCalculator.default {
|
|
8
15
|
constructor(_ref) {
|
|
9
16
|
let {
|
|
10
17
|
value,
|
|
@@ -30,8 +37,8 @@ class TrendCalculator extends BaseCalculator {
|
|
|
30
37
|
summary_type
|
|
31
38
|
} = chart;
|
|
32
39
|
const table = this.getTableById(table_id);
|
|
33
|
-
if (!TableUtils.getTableColumnByKey(table, date_column)) return false;
|
|
34
|
-
if (summary_type === SUMMARY_TYPE.ADVANCED && !TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
40
|
+
if (!_dtableStore.TableUtils.getTableColumnByKey(table, date_column)) return false;
|
|
41
|
+
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED && !_dtableStore.TableUtils.getTableColumnByKey(table, summary_column)) {
|
|
35
42
|
return false;
|
|
36
43
|
}
|
|
37
44
|
return true;
|
|
@@ -55,17 +62,17 @@ class TrendCalculator extends BaseCalculator {
|
|
|
55
62
|
} = chart;
|
|
56
63
|
const selectedTable = this.getTableById(table_id);
|
|
57
64
|
const selectedView = this.getViewById(view_id, selectedTable);
|
|
58
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, date_column);
|
|
65
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, date_column);
|
|
59
66
|
if (!selectedColumn) return {};
|
|
60
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
61
|
-
const numericColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
67
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
68
|
+
const numericColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, summary_column);
|
|
62
69
|
const columnName = selectedColumn.name;
|
|
63
|
-
const dateGroupBy = getSqlGroup(date_granularity, selectedColumn);
|
|
70
|
+
const dateGroupBy = (0, _sqlUtils.getSqlGroup)(date_granularity, selectedColumn);
|
|
64
71
|
let sqlString = '';
|
|
65
|
-
if (summary_type === SUMMARY_TYPE.COUNT) {
|
|
66
|
-
sqlString = "select ".concat(dateGroupBy, ", ").concat(DTABLE_DB_SUMMARY_METHOD.Row_count, "(").concat(columnName, ") from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(dateGroupBy, " order by ").concat(dateGroupBy, " limit 5000");
|
|
72
|
+
if (summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
73
|
+
sqlString = "select ".concat(dateGroupBy, ", ").concat(_constants.DTABLE_DB_SUMMARY_METHOD.Row_count, "(").concat(columnName, ") from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(dateGroupBy, " order by ").concat(dateGroupBy, " limit 5000");
|
|
67
74
|
} else {
|
|
68
|
-
const summaryColumnMethod = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[summary_method], numericColumn.name);
|
|
75
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summary_method], numericColumn.name);
|
|
69
76
|
sqlString = "select ".concat(dateGroupBy, ", ").concat(summaryColumnMethod, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(dateGroupBy, " order by ").concat(dateGroupBy, " limit 5000");
|
|
70
77
|
}
|
|
71
78
|
const result = await this.sqlQuery(sqlString);
|
|
@@ -73,9 +80,9 @@ class TrendCalculator extends BaseCalculator {
|
|
|
73
80
|
const data = result.data;
|
|
74
81
|
if (!data.results) return {};
|
|
75
82
|
const results = data.results;
|
|
76
|
-
let summaryKey = "".concat(DTABLE_DB_SUMMARY_METHOD.Row_count, "(").concat(columnName, ")");
|
|
77
|
-
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
78
|
-
const summaryColumnMethod = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[summary_method], numericColumn.name);
|
|
83
|
+
let summaryKey = "".concat(_constants.DTABLE_DB_SUMMARY_METHOD.Row_count, "(").concat(columnName, ")");
|
|
84
|
+
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
85
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[summary_method], numericColumn.name);
|
|
79
86
|
summaryKey = summaryColumnMethod;
|
|
80
87
|
}
|
|
81
88
|
let compareValue, comparedValue;
|
|
@@ -83,14 +90,14 @@ class TrendCalculator extends BaseCalculator {
|
|
|
83
90
|
const {
|
|
84
91
|
compareValue: value1,
|
|
85
92
|
comparedValue: value2
|
|
86
|
-
} = summaryDurationResult(results, date_granularity, summary_type, summary_method, true, dateGroupBy, summaryKey);
|
|
93
|
+
} = (0, _trendUtils.summaryDurationResult)(results, date_granularity, summary_type, summary_method, true, dateGroupBy, summaryKey);
|
|
87
94
|
compareValue = value1;
|
|
88
95
|
comparedValue = value2;
|
|
89
96
|
} else {
|
|
90
97
|
const {
|
|
91
98
|
compareDate,
|
|
92
99
|
comparedDate
|
|
93
|
-
} = getCompareDate(date_granularity);
|
|
100
|
+
} = (0, _trendUtils.getCompareDate)(date_granularity);
|
|
94
101
|
for (let index = results.length - 1; index >= 0; index--) {
|
|
95
102
|
const item = results[index];
|
|
96
103
|
if (!item[dateGroupBy]) continue;
|
|
@@ -117,4 +124,4 @@ class TrendCalculator extends BaseCalculator {
|
|
|
117
124
|
return {};
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
|
-
|
|
127
|
+
var _default = exports.default = TrendCalculator;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _dtableStore = require("dtable-store");
|
|
9
|
+
var _constants = require("../../constants");
|
|
10
|
+
var _columnUtils = require("../../utils/column-utils");
|
|
11
|
+
var _commonUtils = require("../../utils/common-utils");
|
|
12
|
+
var _rowUtils = require("../../utils/row-utils");
|
|
13
|
+
var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
|
|
14
|
+
var _map = require("../../utils/map");
|
|
15
|
+
const MAP_CHART_TYPES = [_constants.STAT_TYPE.MAP, _constants.STAT_TYPE.WORLD_MAP, _constants.STAT_TYPE.MAP_BUBBLE, _constants.STAT_TYPE.WORLD_MAP_BUBBLE];
|
|
9
16
|
function calculateChart(chart, value, username, userId) {
|
|
10
17
|
const {
|
|
11
18
|
type
|
|
@@ -13,7 +20,7 @@ function calculateChart(chart, value, username, userId) {
|
|
|
13
20
|
if (MAP_CHART_TYPES.includes(type)) {
|
|
14
21
|
return calculateGeolocationBasicChart(chart, value, username, userId);
|
|
15
22
|
}
|
|
16
|
-
if (type === STAT_TYPE.CUSTOM_BAR) {
|
|
23
|
+
if (type === _constants.STAT_TYPE.CUSTOM_BAR) {
|
|
17
24
|
return calculateCustomBar(chart, value, username, userId);
|
|
18
25
|
}
|
|
19
26
|
const {
|
|
@@ -38,7 +45,7 @@ function calculateBasicChart(chart, value, username, userId) {
|
|
|
38
45
|
let groupby_date_granularity;
|
|
39
46
|
let include_empty;
|
|
40
47
|
let groupby_geolocation_granularity;
|
|
41
|
-
if (chart.type === STAT_TYPE.PIE || chart.type === STAT_TYPE.RING || chart.type === STAT_TYPE.TREEMAP) {
|
|
48
|
+
if (chart.type === _constants.STAT_TYPE.PIE || chart.type === _constants.STAT_TYPE.RING || chart.type === _constants.STAT_TYPE.TREEMAP) {
|
|
42
49
|
groupby_column_key = chart.groupby_column_key;
|
|
43
50
|
summary_type = chart.summary_type;
|
|
44
51
|
summary_method = chart.summary_method;
|
|
@@ -55,38 +62,38 @@ function calculateBasicChart(chart, value, username, userId) {
|
|
|
55
62
|
groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
56
63
|
include_empty = chart.x_axis_include_empty;
|
|
57
64
|
}
|
|
58
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
59
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
65
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
66
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
60
67
|
if (!view) {
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
63
|
-
const groupbyColumn = groupby_column_key && TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
70
|
+
const groupbyColumn = groupby_column_key && _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
64
71
|
if (!groupbyColumn) {
|
|
65
72
|
return;
|
|
66
73
|
}
|
|
67
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
74
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
68
75
|
const {
|
|
69
76
|
type: groupby_column_type
|
|
70
77
|
} = groupbyColumn;
|
|
71
|
-
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
72
|
-
groupby_date_granularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
78
|
+
if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
79
|
+
groupby_date_granularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
|
|
73
80
|
}
|
|
74
|
-
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
75
|
-
groupby_geolocation_granularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
81
|
+
if (groupby_column_type === _dtableStore.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
82
|
+
groupby_geolocation_granularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
|
|
76
83
|
}
|
|
77
84
|
const yAxisType = null;
|
|
78
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
79
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
80
|
-
const isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
85
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
86
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
87
|
+
const isGroupbyColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupbyColumn);
|
|
81
88
|
let results = getBasicChartResults(statRows, formulaRows, groupbyColumn, include_empty, isGroupbyColumnDataAsAnArray, groupby_date_granularity, groupby_geolocation_granularity, summaryColumn, summary_type, summary_method, yAxisType, value);
|
|
82
89
|
if (sort_type) {
|
|
83
|
-
|
|
90
|
+
_statUtils.default.sortStatisticData(results, sort_type); // sortby statistic value
|
|
84
91
|
} else {
|
|
85
|
-
|
|
92
|
+
_statUtils.default.sortStatistics(results, groupbyColumn, 'name'); // sortby statistic label
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
results.forEach(item => {
|
|
89
|
-
item.name = getFormattedLabel(groupbyColumn, item.name, value.collaborators);
|
|
96
|
+
item.name = (0, _rowUtils.getFormattedLabel)(groupbyColumn, item.name, value.collaborators);
|
|
90
97
|
});
|
|
91
98
|
return results;
|
|
92
99
|
}
|
|
@@ -108,55 +115,55 @@ function calculateGroupingChart(chart, value, username, userId) {
|
|
|
108
115
|
let groupby_date_granularity = chart.x_axis_date_granularity;
|
|
109
116
|
let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
110
117
|
let column_groupby_numeric_columns = chart.column_groupby_numeric_columns || [];
|
|
111
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
112
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
118
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
119
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
113
120
|
if (!view) {
|
|
114
121
|
return;
|
|
115
122
|
}
|
|
116
|
-
const groupbyColumn = groupby_column_key && TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
123
|
+
const groupbyColumn = groupby_column_key && _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
117
124
|
if (!groupbyColumn) {
|
|
118
125
|
return;
|
|
119
126
|
}
|
|
120
127
|
const {
|
|
121
128
|
type: groupby_column_type
|
|
122
129
|
} = groupbyColumn;
|
|
123
|
-
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
124
|
-
groupby_date_granularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
130
|
+
if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
131
|
+
groupby_date_granularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
|
|
125
132
|
}
|
|
126
|
-
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
127
|
-
groupby_geolocation_granularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
133
|
+
if (groupby_column_type === _dtableStore.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
134
|
+
groupby_geolocation_granularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
|
|
128
135
|
}
|
|
129
136
|
const yAxisType = null;
|
|
130
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
131
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
137
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
138
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
132
139
|
let results = getGroupingChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty, groupby_date_granularity, groupby_geolocation_granularity, column_groupby_column_key, column_groupby_date_granularity, column_groupby_geolocation_granularity, y_axis_column_key, y_axis_summary_type, y_axis_summary_method, column_groupby_multiple_numeric_column, column_groupby_numeric_columns, yAxisType, table, value);
|
|
133
|
-
|
|
140
|
+
_statUtils.default.sortStatistics(results, groupbyColumn, 'name');
|
|
134
141
|
results = results.map(result => {
|
|
135
142
|
return {
|
|
136
143
|
...result,
|
|
137
|
-
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
144
|
+
name: (0, _rowUtils.getFormattedLabel)(groupbyColumn, result.name, value.collaborators)
|
|
138
145
|
};
|
|
139
146
|
});
|
|
140
147
|
return results;
|
|
141
148
|
}
|
|
142
149
|
function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
|
|
143
|
-
let columnGroupbyColumn = TableUtils.getTableColumnByKey(table, groupColumnKey);
|
|
150
|
+
let columnGroupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, groupColumnKey);
|
|
144
151
|
if (!columnGroupbyColumn) {
|
|
145
152
|
return [];
|
|
146
153
|
}
|
|
147
154
|
let result = [];
|
|
148
|
-
let isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
149
|
-
let isColumnGroupbyColumnDataAsAnArray = isArrayCellValue(columnGroupbyColumn);
|
|
155
|
+
let isGroupbyColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupbyColumn);
|
|
156
|
+
let isColumnGroupbyColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(columnGroupbyColumn);
|
|
150
157
|
statRows.forEach(row => {
|
|
151
158
|
let {
|
|
152
159
|
_id: rowId
|
|
153
160
|
} = row;
|
|
154
161
|
let formulaRow = formulaRows[rowId];
|
|
155
|
-
if (isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
156
|
-
let name =
|
|
162
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
163
|
+
let name = _statUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
157
164
|
let groupName = columnGroupbyColumn.name;
|
|
158
165
|
if (!columnGroupbyMultipleNumericColumn) {
|
|
159
|
-
groupName =
|
|
166
|
+
groupName = _statUtils.default.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, value);
|
|
160
167
|
}
|
|
161
168
|
if (isGroupbyColumnDataAsAnArray) {
|
|
162
169
|
if (name.length === 0 && includeEmpty) {
|
|
@@ -245,9 +252,9 @@ function updateChartValue(summaryColumn, summary_type, summary_method, formula_r
|
|
|
245
252
|
let updated = {
|
|
246
253
|
...item
|
|
247
254
|
};
|
|
248
|
-
const value =
|
|
255
|
+
const value = _statUtils.default.getTotal(summaryColumnKey, summaryColumnType, summary_type, summary_method, rows, formula_rows);
|
|
249
256
|
updated.value = value;
|
|
250
|
-
updated.formatted_value =
|
|
257
|
+
updated.formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, summary_method);
|
|
251
258
|
results[index] = updated;
|
|
252
259
|
});
|
|
253
260
|
}
|
|
@@ -258,8 +265,8 @@ function getBasicChartResults(rows, formulaRows, groupbyColumn, includeEmpty, is
|
|
|
258
265
|
_id: rowId
|
|
259
266
|
} = row;
|
|
260
267
|
const formulaRow = formulaRows[rowId];
|
|
261
|
-
if (!isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
262
|
-
const name =
|
|
268
|
+
if (!(0, _rowUtils.isValidRow)(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
269
|
+
const name = _statUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
263
270
|
if (isGroupbyColumnDataAsAnArray) {
|
|
264
271
|
if (name.length === 0 && includeEmpty) {
|
|
265
272
|
const nameIndex = results.findIndex(result => !result.name);
|
|
@@ -302,25 +309,25 @@ function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeE
|
|
|
302
309
|
return results;
|
|
303
310
|
}
|
|
304
311
|
function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumnKey, summaryType, summaryMethod, yAxisType, table, value) {
|
|
305
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
312
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
306
313
|
const columnGroupbyMultipleNumericColumn = false;
|
|
307
314
|
let results = getGroupChartStatResult(table, value, groupbyColumn, columnGroupbyColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
308
|
-
const columnGroupByColumn = TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
315
|
+
const columnGroupByColumn = _dtableStore.TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
309
316
|
results = results.map(result => {
|
|
310
317
|
const groupName = result.group_name;
|
|
311
318
|
let formattedResult = {
|
|
312
319
|
...result
|
|
313
320
|
};
|
|
314
|
-
if (columnGroupByColumn.type === CellType.SINGLE_SELECT) {
|
|
315
|
-
formattedResult.color = getColorFromSingleSelectColumn(columnGroupByColumn, groupName);
|
|
321
|
+
if (columnGroupByColumn.type === _dtableStore.CellType.SINGLE_SELECT) {
|
|
322
|
+
formattedResult.color = (0, _columnUtils.getColorFromSingleSelectColumn)(columnGroupByColumn, groupName);
|
|
316
323
|
}
|
|
317
|
-
formattedResult.group_name = getFormattedLabel(columnGroupByColumn, groupName, value.collaborators);
|
|
324
|
+
formattedResult.group_name = (0, _rowUtils.getFormattedLabel)(columnGroupByColumn, groupName, value.collaborators);
|
|
318
325
|
return formattedResult;
|
|
319
326
|
});
|
|
320
327
|
return results;
|
|
321
328
|
}
|
|
322
329
|
function getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, numericSummaryColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryType, summaryMethod, yAxisType, table, value) {
|
|
323
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, numericSummaryColumnKey);
|
|
330
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, numericSummaryColumnKey);
|
|
324
331
|
const columnGroupbyMultipleNumericColumn = true;
|
|
325
332
|
return getGroupChartStatResult(table, value, groupbyColumn, numericSummaryColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
326
333
|
}
|
|
@@ -334,24 +341,24 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
|
|
|
334
341
|
summary_column,
|
|
335
342
|
summary_method
|
|
336
343
|
} = chart;
|
|
337
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
338
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
344
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
345
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
339
346
|
if (!view) {
|
|
340
347
|
return;
|
|
341
348
|
}
|
|
342
|
-
const geoColumn = geo_column && TableUtils.getTableColumnByKey(table, geo_column);
|
|
349
|
+
const geoColumn = geo_column && _dtableStore.TableUtils.getTableColumnByKey(table, geo_column);
|
|
343
350
|
if (!geoColumn) {
|
|
344
351
|
return;
|
|
345
352
|
}
|
|
346
353
|
let geolocationGranularity = null;
|
|
347
354
|
if (type && type.includes('world')) {
|
|
348
|
-
geolocationGranularity = geoColumn.type === CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
355
|
+
geolocationGranularity = geoColumn.type === _dtableStore.CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
349
356
|
} else {
|
|
350
|
-
geolocationGranularity = fixMapGeoGranularity(chart);
|
|
357
|
+
geolocationGranularity = (0, _map.fixMapGeoGranularity)(chart);
|
|
351
358
|
}
|
|
352
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column);
|
|
353
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
354
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
359
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column);
|
|
360
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
361
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
355
362
|
const geoColumnType = geoColumn.type;
|
|
356
363
|
let results = [];
|
|
357
364
|
statRows.forEach(row => {
|
|
@@ -359,8 +366,8 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
|
|
|
359
366
|
_id: rowId
|
|
360
367
|
} = row;
|
|
361
368
|
const formulaRow = formulaRows[rowId];
|
|
362
|
-
if (isValidRow(row, formulaRow, geoColumn, false)) {
|
|
363
|
-
if (FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
369
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, geoColumn, false)) {
|
|
370
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
364
371
|
const list = formulaRow[geoColumn.key];
|
|
365
372
|
list.forEach(n => {
|
|
366
373
|
const nameIndex = results.findIndex(r => {
|
|
@@ -398,12 +405,12 @@ function calculateCustomBar(statItem, value, username, userId) {
|
|
|
398
405
|
x_axis_include_empty,
|
|
399
406
|
y_axises
|
|
400
407
|
} = statItem;
|
|
401
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
402
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
408
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
409
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
403
410
|
if (!view || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
|
|
404
411
|
return [];
|
|
405
412
|
}
|
|
406
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
413
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
407
414
|
if (!groupbyColumn) {
|
|
408
415
|
return [];
|
|
409
416
|
}
|
|
@@ -412,45 +419,45 @@ function calculateCustomBar(statItem, value, username, userId) {
|
|
|
412
419
|
} = groupbyColumn;
|
|
413
420
|
let groupbyDateGranularity = x_axis_date_granularity;
|
|
414
421
|
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
415
|
-
if (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
|
|
416
|
-
groupbyDateGranularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
422
|
+
if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
|
|
423
|
+
groupbyDateGranularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
|
|
417
424
|
}
|
|
418
|
-
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
419
|
-
groupbyGeolocationGranularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
425
|
+
if (groupbyColumnType === _dtableStore.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
426
|
+
groupbyGeolocationGranularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
|
|
420
427
|
}
|
|
421
428
|
const columnGroupbyDateGranularity = null;
|
|
422
429
|
const columnGroupbyGeolocationGranularity = null;
|
|
423
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
424
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
430
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
431
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
425
432
|
let results = [];
|
|
426
433
|
y_axises.forEach((yAxis, index) => {
|
|
427
434
|
const {
|
|
428
435
|
type: yAxisType,
|
|
429
436
|
column_groupby_numeric_columns
|
|
430
437
|
} = yAxis;
|
|
431
|
-
if (yAxisType === STAT_TYPE.BAR_STACK) {
|
|
438
|
+
if (yAxisType === _constants.STAT_TYPE.BAR_STACK) {
|
|
432
439
|
// just support summary numeric columns.
|
|
433
440
|
if (!Array.isArray(column_groupby_numeric_columns) || column_groupby_numeric_columns.length === 0) {
|
|
434
441
|
return;
|
|
435
442
|
}
|
|
436
|
-
const yAxisType = "".concat(Y_AXIS_TYPE_PREFIX).concat(index);
|
|
443
|
+
const yAxisType = "".concat(_constants.Y_AXIS_TYPE_PREFIX).concat(index);
|
|
437
444
|
column_groupby_numeric_columns.forEach(numericSummaryColumn => {
|
|
438
445
|
const {
|
|
439
446
|
column_key: summary_column_key,
|
|
440
447
|
summary_method
|
|
441
448
|
} = numericSummaryColumn;
|
|
442
|
-
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, STATISTICS_COUNT_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
449
|
+
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, _constants.STATISTICS_COUNT_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
443
450
|
results = results.concat(currentResults);
|
|
444
451
|
});
|
|
445
452
|
}
|
|
446
453
|
});
|
|
447
|
-
|
|
454
|
+
_statUtils.default.sortStatistics(results, groupbyColumn, 'name');
|
|
448
455
|
results = results.map(result => {
|
|
449
456
|
return {
|
|
450
457
|
...result,
|
|
451
|
-
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
458
|
+
name: (0, _rowUtils.getFormattedLabel)(groupbyColumn, result.name, value.collaborators)
|
|
452
459
|
};
|
|
453
460
|
});
|
|
454
461
|
return results;
|
|
455
462
|
}
|
|
456
|
-
|
|
463
|
+
var _default = exports.default = calculateChart;
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _comlink = require("comlink");
|
|
5
|
+
var _pivotTableCalculatorWorker = _interopRequireDefault(require("./pivot-table-calculator-worker"));
|
|
6
|
+
var _basicChartCalculatorWorker = _interopRequireDefault(require("./basic-chart-calculator-worker"));
|
|
7
|
+
var _compareBarChartCalculatorWorker = _interopRequireDefault(require("./compare-bar-chart-calculator-worker"));
|
|
8
|
+
var _completenessCalculatorWorker = _interopRequireDefault(require("./completeness-calculator-worker"));
|
|
9
|
+
var _combinationCalculatorWorker = _interopRequireDefault(require("./combination-calculator-worker"));
|
|
10
|
+
var _scatterCalculatorWorker = _interopRequireDefault(require("./scatter-calculator-worker"));
|
|
11
|
+
var _mirrorCalculatorWorker = _interopRequireDefault(require("./mirror-calculator-worker"));
|
|
12
|
+
var _cardCalculatorWorker = _interopRequireDefault(require("./card-calculator-worker"));
|
|
13
|
+
var _trendCalculatorWorker = _interopRequireDefault(require("./trend-calculator-worker"));
|
|
14
|
+
var _dashboardCalculatorWorker = _interopRequireDefault(require("./dashboard-calculator-worker"));
|
|
15
|
+
var _constants = require("../../constants");
|
|
13
16
|
const BASIC_CHART = 'basic_chart';
|
|
14
17
|
const typeCalculatorWorkerMap = {
|
|
15
|
-
[STAT_TYPE.PIVOT_TABLE]:
|
|
16
|
-
[BASIC_CHART]:
|
|
17
|
-
[STAT_TYPE.COMPARE_BAR]:
|
|
18
|
-
[STAT_TYPE.HORIZONTAL_BAR]:
|
|
19
|
-
[STAT_TYPE.HORIZONTAL_GROUP_BAR]:
|
|
20
|
-
[STAT_TYPE.STACKED_HORIZONTAL_BAR]:
|
|
21
|
-
[STAT_TYPE.COMPLETENESS_CHART]:
|
|
22
|
-
[STAT_TYPE.GROUP_COMPLETENESS_CHART]:
|
|
23
|
-
[STAT_TYPE.SCATTER]:
|
|
24
|
-
[STAT_TYPE.COMBINATION_CHART]:
|
|
25
|
-
[STAT_TYPE.MAP]:
|
|
26
|
-
[STAT_TYPE.WORLD_MAP]:
|
|
27
|
-
[STAT_TYPE.HEAT_MAP]:
|
|
28
|
-
[STAT_TYPE.MIRROR]:
|
|
29
|
-
[STAT_TYPE.BASIC_NUMBER_CARD]:
|
|
30
|
-
[STAT_TYPE.TREND_CHART]:
|
|
31
|
-
[STAT_TYPE.DASHBOARD]:
|
|
18
|
+
[_constants.STAT_TYPE.PIVOT_TABLE]: _pivotTableCalculatorWorker.default,
|
|
19
|
+
[BASIC_CHART]: _basicChartCalculatorWorker.default,
|
|
20
|
+
[_constants.STAT_TYPE.COMPARE_BAR]: _compareBarChartCalculatorWorker.default,
|
|
21
|
+
[_constants.STAT_TYPE.HORIZONTAL_BAR]: _basicChartCalculatorWorker.default,
|
|
22
|
+
[_constants.STAT_TYPE.HORIZONTAL_GROUP_BAR]: _basicChartCalculatorWorker.default,
|
|
23
|
+
[_constants.STAT_TYPE.STACKED_HORIZONTAL_BAR]: _basicChartCalculatorWorker.default,
|
|
24
|
+
[_constants.STAT_TYPE.COMPLETENESS_CHART]: _completenessCalculatorWorker.default,
|
|
25
|
+
[_constants.STAT_TYPE.GROUP_COMPLETENESS_CHART]: _completenessCalculatorWorker.default,
|
|
26
|
+
[_constants.STAT_TYPE.SCATTER]: _scatterCalculatorWorker.default,
|
|
27
|
+
[_constants.STAT_TYPE.COMBINATION_CHART]: _combinationCalculatorWorker.default,
|
|
28
|
+
[_constants.STAT_TYPE.MAP]: _basicChartCalculatorWorker.default,
|
|
29
|
+
[_constants.STAT_TYPE.WORLD_MAP]: _basicChartCalculatorWorker.default,
|
|
30
|
+
[_constants.STAT_TYPE.HEAT_MAP]: _basicChartCalculatorWorker.default,
|
|
31
|
+
[_constants.STAT_TYPE.MIRROR]: _mirrorCalculatorWorker.default,
|
|
32
|
+
[_constants.STAT_TYPE.BASIC_NUMBER_CARD]: _cardCalculatorWorker.default,
|
|
33
|
+
[_constants.STAT_TYPE.TREND_CHART]: _trendCalculatorWorker.default,
|
|
34
|
+
[_constants.STAT_TYPE.DASHBOARD]: _dashboardCalculatorWorker.default
|
|
32
35
|
};
|
|
33
36
|
function calculator(chart, value, username, userId) {
|
|
34
37
|
const type = chart.type;
|
|
35
38
|
const calculatorWorker = typeCalculatorWorkerMap[type] || typeCalculatorWorkerMap[BASIC_CHART];
|
|
36
39
|
return calculatorWorker(chart, value, username, userId);
|
|
37
40
|
}
|
|
38
|
-
expose(calculator);
|
|
41
|
+
(0, _comlink.expose)(calculator);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 _commonUtils = require("../../utils/common-utils");
|
|
9
|
+
var _rowUtils = require("../../utils/row-utils");
|
|
4
10
|
function calculateResult(chart, dtableValue, username, userId) {
|
|
5
11
|
const {
|
|
6
12
|
table_id,
|
|
@@ -8,23 +14,23 @@ function calculateResult(chart, dtableValue, username, userId) {
|
|
|
8
14
|
numeric_column,
|
|
9
15
|
summary_method
|
|
10
16
|
} = chart;
|
|
11
|
-
const selectedTable = TableUtils.getTableById(dtableValue.tables, table_id);
|
|
12
|
-
const selectedView = selectedTable && Views.getViewById(selectedTable.views, view_id);
|
|
13
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, numeric_column);
|
|
14
|
-
const _isNumericColumn = selectedColumn && isNumericColumn(selectedColumn);
|
|
15
|
-
const statRows = Views.getViewRows(selectedView, selectedTable, dtableValue, username, userId);
|
|
16
|
-
const formulaRows = _isNumericColumn ? Views.getTableFormulaResults(selectedTable, statRows, dtableValue) : {};
|
|
17
|
+
const selectedTable = _dtableStore.TableUtils.getTableById(dtableValue.tables, table_id);
|
|
18
|
+
const selectedView = selectedTable && _dtableStore.Views.getViewById(selectedTable.views, view_id);
|
|
19
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, numeric_column);
|
|
20
|
+
const _isNumericColumn = selectedColumn && (0, _dtableStore.isNumericColumn)(selectedColumn);
|
|
21
|
+
const statRows = _dtableStore.Views.getViewRows(selectedView, selectedTable, dtableValue, username, userId);
|
|
22
|
+
const formulaRows = _isNumericColumn ? _dtableStore.Views.getTableFormulaResults(selectedTable, statRows, dtableValue) : {};
|
|
17
23
|
const numberList = [];
|
|
18
24
|
_isNumericColumn && statRows.forEach(row => {
|
|
19
25
|
const formulaRow = formulaRows[row._id];
|
|
20
|
-
const cellValue = getCellValue(row, formulaRow, selectedColumn);
|
|
21
|
-
if (isNumber(cellValue)) {
|
|
26
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn);
|
|
27
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
22
28
|
numberList.push(cellValue);
|
|
23
29
|
}
|
|
24
30
|
});
|
|
25
31
|
if (summary_method === 'Row_count') {
|
|
26
32
|
return statRows.length;
|
|
27
33
|
}
|
|
28
|
-
return getSummaryResult(numberList, summary_method);
|
|
34
|
+
return (0, _commonUtils.getSummaryResult)(numberList, summary_method);
|
|
29
35
|
}
|
|
30
|
-
|
|
36
|
+
var _default = exports.default = calculateResult;
|