dtable-statistic 4.3.1 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +110 -103
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +22 -15
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +56 -43
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +35 -28
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +42 -35
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +32 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +48 -40
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +59 -51
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +20 -12
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +56 -48
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +56 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +20 -12
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +33 -20
- package/es/stat-list/index.js +36 -28
- package/es/stat-view/area-chart.js +51 -44
- package/es/stat-view/bar-chart.js +55 -48
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +57 -50
- package/es/stat-view/compare-chart.js +47 -40
- package/es/stat-view/completeness-chart.js +37 -30
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +59 -52
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +47 -40
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +46 -39
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +45 -38
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +35 -27
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +67 -43
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +34 -24
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +67 -60
- package/es/utils/trend-utils.js +40 -32
- package/package.json +85 -132
package/es/api/dtable-db-api.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
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 _axios = _interopRequireDefault(require("axios"));
|
|
2
9
|
class DTableDbAPI {
|
|
3
10
|
constructor() {
|
|
4
11
|
this.req = null;
|
|
@@ -9,7 +16,7 @@ class DTableDbAPI {
|
|
|
9
16
|
accessToken,
|
|
10
17
|
dtableDb
|
|
11
18
|
} = window.dtable;
|
|
12
|
-
this.req =
|
|
19
|
+
this.req = _axios.default.create({
|
|
13
20
|
baseURL: dtableDb,
|
|
14
21
|
headers: {
|
|
15
22
|
'Authorization': 'Token ' + accessToken
|
|
@@ -34,4 +41,4 @@ class DTableDbAPI {
|
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
const dtableDbAPI = new DTableDbAPI();
|
|
37
|
-
|
|
44
|
+
var _default = exports.default = dtableDbAPI;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var ComLink = _interopRequireWildcard(require("comlink"));
|
|
10
|
+
var _dtableStore = require("dtable-store");
|
|
11
|
+
var _dtableDbApi = _interopRequireDefault(require("../api/dtable-db-api"));
|
|
12
|
+
var _calculatorWorker = _interopRequireDefault(require("./workers/calculator.worker.js"));
|
|
13
|
+
var _copyValue = _interopRequireDefault(require("./copy-value"));
|
|
6
14
|
class BaseCalculator {
|
|
7
15
|
constructor(_ref) {
|
|
8
16
|
let {
|
|
@@ -35,27 +43,27 @@ class BaseCalculator {
|
|
|
35
43
|
} = chart;
|
|
36
44
|
const table = this.getTableById(table_id);
|
|
37
45
|
const view = this.getViewById(view_id, table);
|
|
38
|
-
return Views.isArchiveView(view);
|
|
46
|
+
return _dtableStore.Views.isArchiveView(view);
|
|
39
47
|
}
|
|
40
48
|
getTableById(tableId) {
|
|
41
|
-
return TableUtils.getTableById(this.value.tables, tableId);
|
|
49
|
+
return _dtableStore.TableUtils.getTableById(this.value.tables, tableId);
|
|
42
50
|
}
|
|
43
51
|
getViewById(viewId, table) {
|
|
44
|
-
return table && Views.getViewById(table.views, viewId);
|
|
52
|
+
return table && _dtableStore.Views.getViewById(table.views, viewId);
|
|
45
53
|
}
|
|
46
54
|
async calculateWithWorker(chart) {
|
|
47
55
|
const {
|
|
48
56
|
_id: chartId
|
|
49
57
|
} = chart;
|
|
50
|
-
const calculatorWorker = await this.statisticThreadManager.applyThread(chartId,
|
|
58
|
+
const calculatorWorker = await this.statisticThreadManager.applyThread(chartId, _calculatorWorker.default);
|
|
51
59
|
const calculateChart = ComLink.wrap(calculatorWorker);
|
|
52
|
-
const newValue =
|
|
60
|
+
const newValue = (0, _copyValue.default)(this.value);
|
|
53
61
|
const result = await calculateChart(chart, newValue, this.username, this.userId);
|
|
54
62
|
this.statisticThreadManager.removeThread(chartId);
|
|
55
63
|
return result;
|
|
56
64
|
}
|
|
57
65
|
async sqlQuery(sql) {
|
|
58
|
-
return
|
|
66
|
+
return _dtableDbApi.default.sqlQuery(sql);
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
|
-
|
|
69
|
+
var _default = exports.default = BaseCalculator;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 _constants = require("../constants");
|
|
11
|
+
var _sqlUtils = require("../utils/sql-utils");
|
|
12
|
+
var _commonUtils = require("../utils/common-utils");
|
|
13
|
+
var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
|
|
14
|
+
var _columnUtils = require("../utils/column-utils");
|
|
15
|
+
var _rowUtils = require("../utils/row-utils");
|
|
16
|
+
class BasicChartCalculator extends _baseCalculator.default {
|
|
10
17
|
constructor(_ref) {
|
|
11
18
|
let {
|
|
12
19
|
value,
|
|
@@ -25,7 +32,7 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
25
32
|
if (!this.validateBaseConfigs(chart)) {
|
|
26
33
|
return false;
|
|
27
34
|
}
|
|
28
|
-
if (chart.type === STAT_TYPE.CUSTOM_BAR) {
|
|
35
|
+
if (chart.type === _constants.STAT_TYPE.CUSTOM_BAR) {
|
|
29
36
|
return this.isValidCustomBar(chart);
|
|
30
37
|
}
|
|
31
38
|
const {
|
|
@@ -37,11 +44,11 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
37
44
|
} = chart;
|
|
38
45
|
const table = this.getTableById(table_id);
|
|
39
46
|
const groupbyColumnKey = groupby_column_key || x_axis_column_key;
|
|
40
|
-
if (!groupbyColumnKey || !TableUtils.getTableColumnByKey(table, groupbyColumnKey)) {
|
|
47
|
+
if (!groupbyColumnKey || !_dtableStore.TableUtils.getTableColumnByKey(table, groupbyColumnKey)) {
|
|
41
48
|
return false;
|
|
42
49
|
}
|
|
43
50
|
const summaryColumnKey = summary_column_key || y_axis_column_key;
|
|
44
|
-
if (summaryColumnKey && !TableUtils.getTableColumnByKey(table, summaryColumnKey)) {
|
|
51
|
+
if (summaryColumnKey && !_dtableStore.TableUtils.getTableColumnByKey(table, summaryColumnKey)) {
|
|
45
52
|
return false;
|
|
46
53
|
}
|
|
47
54
|
return true;
|
|
@@ -66,7 +73,7 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
66
73
|
return await this.calculateWithWorker(chart);
|
|
67
74
|
}
|
|
68
75
|
async queryDb(chart) {
|
|
69
|
-
if (chart.type === STAT_TYPE.CUSTOM_BAR) {
|
|
76
|
+
if (chart.type === _constants.STAT_TYPE.CUSTOM_BAR) {
|
|
70
77
|
return this.queryDbFromCustomBar(chart);
|
|
71
78
|
}
|
|
72
79
|
const {
|
|
@@ -77,7 +84,7 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
77
84
|
let groupby_column_key, summary_type, summary_method, summary_column_key, groupby_date_granularity, include_empty, groupby_geolocation_granularity;
|
|
78
85
|
const column_groupby_column_key = chart.column_groupby_column_key;
|
|
79
86
|
const sortType = chart.sort_type;
|
|
80
|
-
if (chart.type === STAT_TYPE.PIE || chart.type === STAT_TYPE.RING || chart.type === STAT_TYPE.TREEMAP) {
|
|
87
|
+
if (chart.type === _constants.STAT_TYPE.PIE || chart.type === _constants.STAT_TYPE.RING || chart.type === _constants.STAT_TYPE.TREEMAP) {
|
|
81
88
|
groupby_column_key = chart.groupby_column_key;
|
|
82
89
|
summary_type = chart.summary_type;
|
|
83
90
|
summary_method = chart.summary_method;
|
|
@@ -100,14 +107,14 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
100
107
|
if (!selectedView) {
|
|
101
108
|
return [];
|
|
102
109
|
}
|
|
103
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
104
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
110
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
|
|
111
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
105
112
|
let groupbyName = "`".concat(groupbyColumn.name, "`");
|
|
106
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupbyColumn.type);
|
|
113
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupbyColumn.type);
|
|
107
114
|
if (isTimeColumn) {
|
|
108
|
-
groupbyName = getSqlGroup(groupby_date_granularity, groupbyColumn);
|
|
109
|
-
} else if (groupbyColumn.type === CellType.GEOLOCATION) {
|
|
110
|
-
groupbyName = getSqlGroup(groupby_geolocation_granularity, groupbyColumn);
|
|
115
|
+
groupbyName = (0, _sqlUtils.getSqlGroup)(groupby_date_granularity, groupbyColumn);
|
|
116
|
+
} else if (groupbyColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
117
|
+
groupbyName = (0, _sqlUtils.getSqlGroup)(groupby_geolocation_granularity, groupbyColumn);
|
|
111
118
|
}
|
|
112
119
|
let results;
|
|
113
120
|
if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
|
|
@@ -116,7 +123,7 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
116
123
|
const {
|
|
117
124
|
column_groupby_numeric_columns
|
|
118
125
|
} = chart;
|
|
119
|
-
const summaryColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column_key);
|
|
126
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, summary_column_key);
|
|
120
127
|
if (!summaryColumn) return [];
|
|
121
128
|
results = await this.getGroupbyMultipleNumericColumnsResults(groupbyName, groupbyColumn, groupby_date_granularity, groupby_geolocation_granularity, include_empty, summary_type, summaryColumn, summary_method, column_groupby_numeric_columns, sqlCondition, selectedTable, yAxisType);
|
|
122
129
|
} else {
|
|
@@ -126,7 +133,7 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
126
133
|
} = chart;
|
|
127
134
|
results = await this.getGroupbyOneColumnResults(groupbyName, groupbyColumn, groupby_date_granularity, groupby_geolocation_granularity, include_empty, summary_type, summary_column_key, summary_method, column_groupby_column_key, column_groupby_date_granularity, column_groupby_geolocation_granularity, sqlCondition, selectedTable, yAxisType);
|
|
128
135
|
}
|
|
129
|
-
sortType &&
|
|
136
|
+
sortType && _statUtils.default.sortStatisticData(results, sortType);
|
|
130
137
|
return results;
|
|
131
138
|
}
|
|
132
139
|
async queryDbFromCustomBar(chart) {
|
|
@@ -145,19 +152,19 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
145
152
|
if (!selectedView || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
|
|
146
153
|
return [];
|
|
147
154
|
}
|
|
148
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
155
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
149
156
|
if (!groupbyColumn) {
|
|
150
157
|
return [];
|
|
151
158
|
}
|
|
152
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
153
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupbyColumn.type);
|
|
159
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
160
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupbyColumn.type);
|
|
154
161
|
let groupbyName = "`".concat(groupbyColumn.name, "`");
|
|
155
162
|
if (isTimeColumn) {
|
|
156
|
-
groupbyName = getSqlGroup(x_axis_date_granularity, groupbyColumn);
|
|
157
|
-
} else if (groupbyColumn.type === CellType.GEOLOCATION) {
|
|
158
|
-
groupbyName = getSqlGroup(x_axis_geolocation_granularity, groupbyColumn);
|
|
163
|
+
groupbyName = (0, _sqlUtils.getSqlGroup)(x_axis_date_granularity, groupbyColumn);
|
|
164
|
+
} else if (groupbyColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
165
|
+
groupbyName = (0, _sqlUtils.getSqlGroup)(x_axis_geolocation_granularity, groupbyColumn);
|
|
159
166
|
}
|
|
160
|
-
const summaryType = SUMMARY_TYPE.ADVANCED;
|
|
167
|
+
const summaryType = _constants.SUMMARY_TYPE.ADVANCED;
|
|
161
168
|
const yAxisSummaryColumn = null;
|
|
162
169
|
const yAxisSummaryMethod = null;
|
|
163
170
|
let results = [];
|
|
@@ -167,31 +174,31 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
167
174
|
type: yAxisType,
|
|
168
175
|
column_groupby_numeric_columns
|
|
169
176
|
} = stack;
|
|
170
|
-
if (yAxisType === STAT_TYPE.BAR_STACK) {
|
|
177
|
+
if (yAxisType === _constants.STAT_TYPE.BAR_STACK) {
|
|
171
178
|
// just support summary numeric columns.
|
|
172
179
|
if (!Array.isArray(column_groupby_numeric_columns) || column_groupby_numeric_columns.length === 0) {
|
|
173
180
|
continue;
|
|
174
181
|
}
|
|
175
|
-
const yAxisType = "".concat(Y_AXIS_TYPE_PREFIX).concat(i);
|
|
182
|
+
const yAxisType = "".concat(_constants.Y_AXIS_TYPE_PREFIX).concat(i);
|
|
176
183
|
const currentResults = await this.getGroupbyMultipleNumericColumnsResults(groupbyName, groupbyColumn, x_axis_date_granularity, x_axis_geolocation_granularity, x_axis_include_empty, summaryType, yAxisSummaryColumn, yAxisSummaryMethod, column_groupby_numeric_columns, sqlCondition, selectedTable, yAxisType);
|
|
177
184
|
results = results.concat(currentResults);
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
|
-
sort_type &&
|
|
187
|
+
sort_type && _statUtils.default.sortStatisticData(results, sort_type);
|
|
181
188
|
return results;
|
|
182
189
|
}
|
|
183
190
|
async getNoneGroupbyResults(groupbyName, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, includeEmpty, summaryType, summaryColumnKey, summaryMethod, sortType, sqlCondition, table, yAxisType) {
|
|
184
|
-
const isAdvanced = summaryType === SUMMARY_TYPE.ADVANCED;
|
|
191
|
+
const isAdvanced = summaryType === _constants.SUMMARY_TYPE.ADVANCED;
|
|
185
192
|
let selectedSummaryColumn;
|
|
186
193
|
let summaryColumnName = "`".concat(groupbyColumn.name, "`");
|
|
187
194
|
if (isAdvanced) {
|
|
188
|
-
selectedSummaryColumn = TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
195
|
+
selectedSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
189
196
|
if (!selectedSummaryColumn) return [];
|
|
190
197
|
summaryColumnName = selectedSummaryColumn.name;
|
|
191
198
|
}
|
|
192
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
193
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
194
|
-
const sqlOrder = getSqlOrder(sortType, groupbyName);
|
|
199
|
+
const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
200
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
201
|
+
const sqlOrder = (0, _sqlUtils.getSqlOrder)(sortType, groupbyName);
|
|
195
202
|
const sqlString = "select ".concat(groupbyName, ", ").concat(summaryColumnMethod, " from `").concat(table.name, "` ").concat(sqlCondition, " group by ").concat(groupbyName, " ").concat(sqlOrder, " limit 5000");
|
|
196
203
|
const queryResult = await this.sqlQuery(sqlString);
|
|
197
204
|
if (queryResult.status !== 200 || !queryResult.data.success) {
|
|
@@ -209,8 +216,8 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
209
216
|
let value = item[valueKey] || 0;
|
|
210
217
|
let formatted_value = value;
|
|
211
218
|
if (isAdvanced) {
|
|
212
|
-
value = formatNumericValue(value, selectedSummaryColumn);
|
|
213
|
-
formatted_value =
|
|
219
|
+
value = (0, _commonUtils.formatNumericValue)(value, selectedSummaryColumn);
|
|
220
|
+
formatted_value = _statUtils.default.getFormattedValue(value, selectedSummaryColumn, summaryMethod);
|
|
214
221
|
}
|
|
215
222
|
newResult.push({
|
|
216
223
|
name: label,
|
|
@@ -223,23 +230,23 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
223
230
|
return newResult;
|
|
224
231
|
}
|
|
225
232
|
async getGroupbyOneColumnResults(groupbyName, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, includeEmpty, summaryType, summaryColumnKey, summaryMethod, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, sqlCondition, table, yAxisType) {
|
|
226
|
-
const isAdvanced = summaryType === SUMMARY_TYPE.ADVANCED;
|
|
233
|
+
const isAdvanced = summaryType === _constants.SUMMARY_TYPE.ADVANCED;
|
|
227
234
|
let selectedSummaryColumn;
|
|
228
235
|
let summaryColumnName = "`".concat(groupbyColumn.name, "`");
|
|
229
236
|
if (isAdvanced) {
|
|
230
|
-
selectedSummaryColumn = TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
237
|
+
selectedSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
231
238
|
if (!selectedSummaryColumn) return [];
|
|
232
239
|
summaryColumnName = selectedSummaryColumn.name;
|
|
233
240
|
}
|
|
234
|
-
const columnGroupbyColumn = TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
241
|
+
const columnGroupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
235
242
|
let columnGroupbyColumnName = "`".concat(columnGroupbyColumn.name, "`");
|
|
236
|
-
if (TIME_COLUMN_LIST.includes(columnGroupbyColumn.type)) {
|
|
237
|
-
columnGroupbyColumnName = getSqlGroup(columnGroupbyDateGranularity, columnGroupbyColumn);
|
|
238
|
-
} else if (columnGroupbyColumn.type === CellType.GEOLOCATION) {
|
|
239
|
-
columnGroupbyColumnName = getSqlGroup(columnGroupbyGeolocationGranularity, columnGroupbyColumn);
|
|
243
|
+
if (_constants.TIME_COLUMN_LIST.includes(columnGroupbyColumn.type)) {
|
|
244
|
+
columnGroupbyColumnName = (0, _sqlUtils.getSqlGroup)(columnGroupbyDateGranularity, columnGroupbyColumn);
|
|
245
|
+
} else if (columnGroupbyColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
246
|
+
columnGroupbyColumnName = (0, _sqlUtils.getSqlGroup)(columnGroupbyGeolocationGranularity, columnGroupbyColumn);
|
|
240
247
|
}
|
|
241
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
242
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
248
|
+
const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
249
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
243
250
|
const sqlString = "select ".concat(groupbyName, ", ").concat(columnGroupbyColumnName, ", ").concat(summaryColumnMethod, " from `").concat(table.name, "` ").concat(sqlCondition, " group by ").concat(groupbyName, ", ").concat(columnGroupbyColumnName, " order by ").concat(groupbyName, " limit 5000");
|
|
244
251
|
const queryResult = await this.sqlQuery(sqlString);
|
|
245
252
|
if (queryResult.status !== 200 || !queryResult.data.success) {
|
|
@@ -257,13 +264,13 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
257
264
|
let value = item[valueKey] || 0;
|
|
258
265
|
let formatted_value = value;
|
|
259
266
|
if (isAdvanced) {
|
|
260
|
-
value = formatNumericValue(value, selectedSummaryColumn);
|
|
261
|
-
formatted_value =
|
|
267
|
+
value = (0, _commonUtils.formatNumericValue)(value, selectedSummaryColumn);
|
|
268
|
+
formatted_value = _statUtils.default.getFormattedValue(value, selectedSummaryColumn, summaryMethod);
|
|
262
269
|
}
|
|
263
270
|
let color;
|
|
264
|
-
if (columnGroupbyColumn.type === CellType.SINGLE_SELECT) {
|
|
265
|
-
const tempValue =
|
|
266
|
-
color = getColorFromSingleSelectColumn(columnGroupbyColumn, tempValue);
|
|
271
|
+
if (columnGroupbyColumn.type === _dtableStore.CellType.SINGLE_SELECT) {
|
|
272
|
+
const tempValue = _statUtils.default.getGroupLabel(item[columnGroupbyColumn.key], item, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, this.value);
|
|
273
|
+
color = (0, _columnUtils.getColorFromSingleSelectColumn)(columnGroupbyColumn, tempValue);
|
|
267
274
|
}
|
|
268
275
|
const groupLabel = this.getLabel(columnGroupbyColumn, columnGroupbyColumnName, item, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity);
|
|
269
276
|
newResult.push({
|
|
@@ -280,26 +287,26 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
280
287
|
return newResult;
|
|
281
288
|
}
|
|
282
289
|
async getGroupbyMultipleNumericColumnsResults(groupbyName, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, includeEmpty, summaryType, summaryColumn, summaryMethod, columnGroupbyNumericColumns, sqlCondition, table, yAxisType) {
|
|
283
|
-
const isAdvanced = summaryType === SUMMARY_TYPE.ADVANCED;
|
|
290
|
+
const isAdvanced = summaryType === _constants.SUMMARY_TYPE.ADVANCED;
|
|
284
291
|
let numericColumns = [];
|
|
285
292
|
let groupColumnNames = [];
|
|
286
293
|
let groupMethods = [];
|
|
287
294
|
let originalMethods = [];
|
|
288
295
|
if (summaryColumn) {
|
|
289
296
|
const summaryColumnName = isAdvanced ? summaryColumn.name : "`".concat(groupbyColumn.name, "`");
|
|
290
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
291
|
-
const summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
|
|
297
|
+
const method = isAdvanced ? _constants.DTABLE_DB_SUMMARY_METHOD[summaryMethod] : 'COUNT';
|
|
298
|
+
const summaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(method, summaryColumnName);
|
|
292
299
|
numericColumns.push(summaryColumn);
|
|
293
300
|
groupColumnNames.push(summaryColumnName);
|
|
294
301
|
groupMethods.push(summaryColumnMethod);
|
|
295
302
|
originalMethods.push(summaryMethod);
|
|
296
303
|
}
|
|
297
304
|
columnGroupbyNumericColumns.forEach(item => {
|
|
298
|
-
const numericColumn = TableUtils.getTableColumnByKey(table, item.column_key);
|
|
305
|
+
const numericColumn = _dtableStore.TableUtils.getTableColumnByKey(table, item.column_key);
|
|
299
306
|
const groupColumnName = numericColumn.name;
|
|
300
307
|
numericColumns.push(numericColumn);
|
|
301
308
|
groupColumnNames.push(groupColumnName);
|
|
302
|
-
groupMethods.push(getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[item.summary_method], groupColumnName));
|
|
309
|
+
groupMethods.push((0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[item.summary_method], groupColumnName));
|
|
303
310
|
originalMethods.push(item.summary_method);
|
|
304
311
|
});
|
|
305
312
|
const sqlString = "select ".concat(groupbyName, ", ").concat(groupMethods.join(','), " from `").concat(table.name, "` ").concat(sqlCondition, " group by ").concat(groupbyName, " order by ").concat(groupbyName, " limit 5000");
|
|
@@ -321,8 +328,8 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
321
328
|
let value = item[groupMethods[index]] || 0;
|
|
322
329
|
let formatted_value = value;
|
|
323
330
|
if (isAdvanced) {
|
|
324
|
-
value = formatNumericValue(value, numericColumns[index]);
|
|
325
|
-
formatted_value =
|
|
331
|
+
value = (0, _commonUtils.formatNumericValue)(value, numericColumns[index]);
|
|
332
|
+
formatted_value = _statUtils.default.getFormattedValue(value, numericColumns[index], originalMethods[index]);
|
|
326
333
|
}
|
|
327
334
|
groupItems.push({
|
|
328
335
|
name: label,
|
|
@@ -338,14 +345,14 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
338
345
|
return newResult;
|
|
339
346
|
}
|
|
340
347
|
getLabel(groupColumn, groupName, item, groupby_date_granularity, groupby_geolocation_granularity) {
|
|
341
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
348
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
342
349
|
let label;
|
|
343
|
-
if (isTimeColumn || groupColumn.type === CellType.GEOLOCATION) {
|
|
350
|
+
if (isTimeColumn || groupColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
344
351
|
label = item[groupName];
|
|
345
352
|
} else {
|
|
346
353
|
const currentGroupLabel = item[groupColumn.key];
|
|
347
|
-
label =
|
|
348
|
-
label = getFormattedLabel(groupColumn, label, this.value.collaborators);
|
|
354
|
+
label = _statUtils.default.getGroupLabel(currentGroupLabel, item, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
|
|
355
|
+
label = (0, _rowUtils.getFormattedLabel)(groupColumn, label, this.value.collaborators);
|
|
349
356
|
}
|
|
350
357
|
return label;
|
|
351
358
|
}
|
|
@@ -353,4 +360,4 @@ class BasicChartCalculator extends BaseCalculator {
|
|
|
353
360
|
return !label;
|
|
354
361
|
}
|
|
355
362
|
}
|
|
356
|
-
|
|
363
|
+
var _default = exports.default = BasicChartCalculator;
|
|
@@ -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 _baseCalculator = _interopRequireDefault(require("./base-calculator"));
|
|
10
|
+
var _statUtils = _interopRequireDefault(require("../utils/stat-utils"));
|
|
11
|
+
var _commonUtils = require("../utils/common-utils");
|
|
12
|
+
var _rowUtils = require("../utils/row-utils");
|
|
13
|
+
var _sqlUtils = require("../utils/sql-utils");
|
|
14
|
+
var _constants = require("../constants");
|
|
15
|
+
class CombinationCalculator extends _baseCalculator.default {
|
|
9
16
|
constructor(_ref) {
|
|
10
17
|
let {
|
|
11
18
|
value,
|
|
@@ -38,14 +45,14 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
38
45
|
y_axis_left_summary_type
|
|
39
46
|
} = chart;
|
|
40
47
|
const table = this.getTableById(table_id);
|
|
41
|
-
if (x_axis_column_key && !TableUtils.getTableColumnByKey(table, x_axis_column_key)) {
|
|
48
|
+
if (x_axis_column_key && !_dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key)) {
|
|
42
49
|
return false;
|
|
43
50
|
}
|
|
44
51
|
if (!y_axis_left_summary_type || !y_axis_right_summary_type) return false;
|
|
45
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED && y_axis_left_summary_method && !TableUtils.getTableColumnByKey(table, y_axis_left_summary_column)) {
|
|
52
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED && y_axis_left_summary_method && !_dtableStore.TableUtils.getTableColumnByKey(table, y_axis_left_summary_column)) {
|
|
46
53
|
return false;
|
|
47
54
|
}
|
|
48
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED && y_axis_right_summary_method && !TableUtils.getTableColumnByKey(table, y_axis_right_summary_column)) {
|
|
55
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED && y_axis_right_summary_method && !_dtableStore.TableUtils.getTableColumnByKey(table, y_axis_right_summary_column)) {
|
|
49
56
|
return false;
|
|
50
57
|
}
|
|
51
58
|
return true;
|
|
@@ -74,13 +81,13 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
74
81
|
y_axis_left_group_by_numeric_columns
|
|
75
82
|
} = chart;
|
|
76
83
|
const selectedTable = this.getTableById(table_id);
|
|
77
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
84
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
78
85
|
if (!selectedColumn) return [];
|
|
79
86
|
let groupName = "`".concat(selectedColumn.name, "`");
|
|
80
|
-
if (TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
81
|
-
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
82
|
-
} else if (selectedColumn.type === CellType.GEOLOCATION) {
|
|
83
|
-
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
87
|
+
if (_constants.TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
88
|
+
groupName = (0, _sqlUtils.getSqlGroup)(groupby_date_granularity, selectedColumn);
|
|
89
|
+
} else if (selectedColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
90
|
+
groupName = (0, _sqlUtils.getSqlGroup)(groupby_geolocation_granularity, selectedColumn);
|
|
84
91
|
}
|
|
85
92
|
let sqlString = this.getSqlString(chart, groupName);
|
|
86
93
|
const result = await this.sqlQuery(sqlString);
|
|
@@ -93,14 +100,14 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
93
100
|
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
94
101
|
let value1Key = "COUNT(".concat(selectedColumn.name, ")");
|
|
95
102
|
let leftSummaryColumn, rightSummaryColumn;
|
|
96
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
97
|
-
leftSummaryColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
98
|
-
value1Key = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], leftSummaryColumn.name);
|
|
103
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
104
|
+
leftSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
105
|
+
value1Key = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], leftSummaryColumn.name);
|
|
99
106
|
}
|
|
100
107
|
let value2Key = "COUNT(".concat(selectedColumn.name, ")");
|
|
101
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
102
|
-
rightSummaryColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
103
|
-
value2Key = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], rightSummaryColumn.name);
|
|
108
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
109
|
+
rightSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
110
|
+
value2Key = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], rightSummaryColumn.name);
|
|
104
111
|
}
|
|
105
112
|
data.forEach(item => {
|
|
106
113
|
let label = this.getLabel(selectedColumn, groupName, item, groupby_date_granularity, groupby_geolocation_granularity);
|
|
@@ -108,13 +115,13 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
108
115
|
let value2 = item[value2Key] || 0;
|
|
109
116
|
let formattedValueLeft = value1;
|
|
110
117
|
let formattedValueRight = value2;
|
|
111
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
112
|
-
value1 = formatNumericValue(value1, leftSummaryColumn);
|
|
113
|
-
formattedValueLeft =
|
|
118
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
119
|
+
value1 = (0, _commonUtils.formatNumericValue)(value1, leftSummaryColumn);
|
|
120
|
+
formattedValueLeft = _statUtils.default.getFormattedValue(value1, leftSummaryColumn, y_axis_left_summary_method);
|
|
114
121
|
}
|
|
115
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
116
|
-
value2 = formatNumericValue(value2, rightSummaryColumn);
|
|
117
|
-
formattedValueRight =
|
|
122
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
123
|
+
value2 = (0, _commonUtils.formatNumericValue)(value2, rightSummaryColumn);
|
|
124
|
+
formattedValueRight = _statUtils.default.getFormattedValue(value2, rightSummaryColumn, y_axis_right_summary_method);
|
|
118
125
|
}
|
|
119
126
|
if (!this.isEmptyLabel(label) || x_axis_include_empty) {
|
|
120
127
|
newResult.push({
|
|
@@ -130,14 +137,14 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
130
137
|
} else {
|
|
131
138
|
let rightSummaryColumn;
|
|
132
139
|
let value2Key = "COUNT(".concat(selectedColumn.name, ")");
|
|
133
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
134
|
-
rightSummaryColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
135
|
-
value2Key = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], rightSummaryColumn.name);
|
|
140
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
141
|
+
rightSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
142
|
+
value2Key = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], rightSummaryColumn.name);
|
|
136
143
|
}
|
|
137
144
|
const groupItems = [];
|
|
138
145
|
let summaries = [];
|
|
139
|
-
let leftSummaryColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
140
|
-
const groupItem = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], leftSummaryColumn.name);
|
|
146
|
+
let leftSummaryColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
147
|
+
const groupItem = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], leftSummaryColumn.name);
|
|
141
148
|
if (leftSummaryColumn && !groupItems.includes(groupItem)) {
|
|
142
149
|
groupItems.push(groupItem);
|
|
143
150
|
summaries.push({
|
|
@@ -146,10 +153,10 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
146
153
|
});
|
|
147
154
|
}
|
|
148
155
|
y_axis_left_group_by_numeric_columns.forEach((item, index) => {
|
|
149
|
-
const column = TableUtils.getTableColumnByKey(selectedTable, item.column_key);
|
|
156
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, item.column_key);
|
|
150
157
|
if (column) {
|
|
151
158
|
const method = item.summary_method;
|
|
152
|
-
const groupItem = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[method], column.name);
|
|
159
|
+
const groupItem = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[method], column.name);
|
|
153
160
|
if (!groupItems.includes(groupItem)) {
|
|
154
161
|
groupItems.push(groupItem);
|
|
155
162
|
summaries.push({
|
|
@@ -163,9 +170,9 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
163
170
|
let label = this.getLabel(selectedColumn, groupName, item, groupby_date_granularity, groupby_geolocation_granularity);
|
|
164
171
|
let value2 = item[value2Key] || 0;
|
|
165
172
|
let formattedValueRight = value2;
|
|
166
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
167
|
-
value2 = formatNumericValue(value2, rightSummaryColumn);
|
|
168
|
-
formattedValueRight =
|
|
173
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
174
|
+
value2 = (0, _commonUtils.formatNumericValue)(value2, rightSummaryColumn);
|
|
175
|
+
formattedValueRight = _statUtils.default.getFormattedValue(value2, rightSummaryColumn, y_axis_right_summary_method);
|
|
169
176
|
}
|
|
170
177
|
groupItems.forEach((groupItem, index) => {
|
|
171
178
|
if (!this.isEmptyLabel(label) || x_axis_include_empty) {
|
|
@@ -174,15 +181,15 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
174
181
|
method,
|
|
175
182
|
column
|
|
176
183
|
} = summary;
|
|
177
|
-
let value = formatNumericValue(item[groupItems[index]] || 0, column);
|
|
178
|
-
let formattedValueLeft =
|
|
184
|
+
let value = (0, _commonUtils.formatNumericValue)(item[groupItems[index]] || 0, column);
|
|
185
|
+
let formattedValueLeft = _statUtils.default.getFormattedValue(value, column, method);
|
|
179
186
|
newResult.push({
|
|
180
187
|
name: label,
|
|
181
188
|
value_left: value,
|
|
182
189
|
value_right: value2,
|
|
183
190
|
formatted_value_left: formattedValueLeft,
|
|
184
191
|
formatted_value_right: formattedValueRight,
|
|
185
|
-
color: LABEL_COLORS[index % 12],
|
|
192
|
+
color: _constants.LABEL_COLORS[index % 12],
|
|
186
193
|
original_name: item[selectedColumn.key]
|
|
187
194
|
});
|
|
188
195
|
}
|
|
@@ -208,27 +215,27 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
208
215
|
} = chart;
|
|
209
216
|
const selectedTable = this.getTableById(table_id);
|
|
210
217
|
let selectedView = this.getViewById(view_id, selectedTable);
|
|
211
|
-
const selectedColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
212
|
-
const column1 = TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
213
|
-
const column2 = TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
218
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
|
|
219
|
+
const column1 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_left_summary_column);
|
|
220
|
+
const column2 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_right_summary_column);
|
|
214
221
|
if (!selectedColumn) return [];
|
|
215
|
-
const sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
222
|
+
const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
|
|
216
223
|
const sqlItems = [];
|
|
217
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.COUNT || y_axis_right_summary_type === SUMMARY_TYPE.COUNT) {
|
|
224
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.COUNT || y_axis_right_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
218
225
|
sqlItems.push("COUNT(`".concat(selectedColumn.name, "`)"));
|
|
219
226
|
}
|
|
220
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED && column2) {
|
|
221
|
-
const rightSummaryColumnMethod = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], column2.name);
|
|
227
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED && column2) {
|
|
228
|
+
const rightSummaryColumnMethod = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_right_summary_method], column2.name);
|
|
222
229
|
sqlItems.push("".concat(rightSummaryColumnMethod));
|
|
223
230
|
}
|
|
224
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED && column1) {
|
|
225
|
-
let groupItem = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], column1.name);
|
|
231
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED && column1) {
|
|
232
|
+
let groupItem = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[y_axis_left_summary_method], column1.name);
|
|
226
233
|
!sqlItems.includes(groupItem) && sqlItems.push(groupItem);
|
|
227
234
|
if (y_axis_left_group_by_multiple_numeric_column) {
|
|
228
235
|
y_axis_left_group_by_numeric_columns.forEach((item, index) => {
|
|
229
|
-
const column = TableUtils.getTableColumnByKey(selectedTable, item.column_key);
|
|
236
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, item.column_key);
|
|
230
237
|
if (column) {
|
|
231
|
-
groupItem = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[item.summary_method], column.name);
|
|
238
|
+
groupItem = (0, _commonUtils.getSummaryColumnMethod)(_constants.DTABLE_DB_SUMMARY_METHOD[item.summary_method], column.name);
|
|
232
239
|
!sqlItems.includes(groupItem) && sqlItems.push(groupItem);
|
|
233
240
|
}
|
|
234
241
|
});
|
|
@@ -238,16 +245,16 @@ class CombinationCalculator extends BaseCalculator {
|
|
|
238
245
|
return "select ".concat(groupName, ", ").concat(sqlColumn, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, " order by ").concat(groupName, " limit 5000");
|
|
239
246
|
}
|
|
240
247
|
getLabel(groupColumn, groupName, item, groupby_date_granularity, groupby_geolocation_granularity) {
|
|
241
|
-
const isTimeColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
248
|
+
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
242
249
|
let label;
|
|
243
|
-
if (isTimeColumn || groupColumn.type === CellType.GEOLOCATION) {
|
|
250
|
+
if (isTimeColumn || groupColumn.type === _dtableStore.CellType.GEOLOCATION) {
|
|
244
251
|
label = item[groupName];
|
|
245
252
|
} else {
|
|
246
253
|
const currentGroupLabel = item[groupColumn.key];
|
|
247
|
-
label =
|
|
248
|
-
label = getFormattedLabel(groupColumn, label);
|
|
254
|
+
label = _statUtils.default.getGroupLabel(currentGroupLabel, item, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
|
|
255
|
+
label = (0, _rowUtils.getFormattedLabel)(groupColumn, label);
|
|
249
256
|
}
|
|
250
257
|
return label;
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
|
-
|
|
260
|
+
var _default = exports.default = CombinationCalculator;
|