dtable-statistic 4.3.2 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +110 -103
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +22 -15
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +56 -43
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +35 -28
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +42 -35
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +32 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +48 -40
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +59 -51
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +20 -12
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +56 -48
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +56 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +20 -12
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +33 -20
- package/es/stat-list/index.js +36 -28
- package/es/stat-view/area-chart.js +51 -44
- package/es/stat-view/bar-chart.js +55 -48
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +57 -50
- package/es/stat-view/compare-chart.js +47 -40
- package/es/stat-view/completeness-chart.js +37 -30
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +59 -52
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +47 -40
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +46 -39
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +45 -38
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +35 -27
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +67 -43
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +34 -24
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +67 -60
- package/es/utils/trend-utils.js +40 -32
- package/package.json +82 -125
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 = calculateResult;
|
|
8
|
+
var _dtableStore = require("dtable-store");
|
|
9
|
+
var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
|
|
10
|
+
var _commonUtils = require("../../utils/common-utils");
|
|
11
|
+
var _constants = require("../../constants");
|
|
12
|
+
var _rowUtils = require("../../utils/row-utils");
|
|
13
|
+
function calculateResult(chart, value, username, userId) {
|
|
7
14
|
const {
|
|
8
15
|
table_id,
|
|
9
16
|
view_id,
|
|
@@ -20,42 +27,42 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
20
27
|
y_axis_left_group_by_multiple_numeric_column,
|
|
21
28
|
y_axis_left_group_by_numeric_columns
|
|
22
29
|
} = chart;
|
|
23
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
24
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
30
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
31
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
25
32
|
if (!view) {
|
|
26
33
|
return [];
|
|
27
34
|
}
|
|
28
|
-
const xAxisColumn = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
35
|
+
const xAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
29
36
|
if (!xAxisColumn) return [];
|
|
30
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
31
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
32
|
-
const column1 = TableUtils.getTableColumnByKey(table, y_axis_left_summary_column);
|
|
33
|
-
const column2 = TableUtils.getTableColumnByKey(table, y_axis_right_summary_column);
|
|
37
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
38
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
39
|
+
const column1 = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_left_summary_column);
|
|
40
|
+
const column2 = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_right_summary_column);
|
|
34
41
|
const leftResultMap = new Map();
|
|
35
42
|
const rightResultMap = new Map();
|
|
36
|
-
let isColumnDataAsAnArray = isArrayCellValue(xAxisColumn);
|
|
43
|
+
let isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(xAxisColumn);
|
|
37
44
|
let leftSummaryColumn = {};
|
|
38
45
|
let leftSummaryColumnKeys = [];
|
|
39
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
46
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
40
47
|
if (column1) {
|
|
41
48
|
leftSummaryColumn[y_axis_left_summary_column] = {
|
|
42
49
|
method: y_axis_left_summary_method,
|
|
43
50
|
column_name: column1.name,
|
|
44
51
|
type: column1.type,
|
|
45
52
|
data: column1.data,
|
|
46
|
-
color: LABEL_COLORS[0]
|
|
53
|
+
color: _constants.LABEL_COLORS[0]
|
|
47
54
|
};
|
|
48
55
|
}
|
|
49
56
|
if (y_axis_left_group_by_multiple_numeric_column) {
|
|
50
57
|
y_axis_left_group_by_numeric_columns.forEach((item, index) => {
|
|
51
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, item.column_key);
|
|
58
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, item.column_key);
|
|
52
59
|
if (summaryColumn) {
|
|
53
60
|
leftSummaryColumn[item.column_key] = {
|
|
54
61
|
method: item.summary_method,
|
|
55
62
|
column_name: summaryColumn.name,
|
|
56
63
|
type: summaryColumn.type,
|
|
57
64
|
data: summaryColumn.data,
|
|
58
|
-
color: LABEL_COLORS[(index + 1) % 12]
|
|
65
|
+
color: _constants.LABEL_COLORS[(index + 1) % 12]
|
|
59
66
|
};
|
|
60
67
|
}
|
|
61
68
|
});
|
|
@@ -68,10 +75,10 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
68
75
|
} = row;
|
|
69
76
|
let formulaRow = formulaRows[rowId];
|
|
70
77
|
const currentValue = row[xAxisColumn.key];
|
|
71
|
-
let label =
|
|
78
|
+
let label = _statUtils.default.getGroupLabel(currentValue, formulaRow, xAxisColumn, groupby_date_granularity, groupby_geolocation_granularity, value);
|
|
72
79
|
|
|
73
80
|
// collect left y axis data
|
|
74
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.COUNT) {
|
|
81
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
75
82
|
if (isColumnDataAsAnArray) {
|
|
76
83
|
if (label.length > 0) {
|
|
77
84
|
label.forEach(name => {
|
|
@@ -93,18 +100,18 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
103
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
97
104
|
if (isColumnDataAsAnArray) {
|
|
98
105
|
if (label.length > 0) {
|
|
99
106
|
label.forEach(name => {
|
|
100
107
|
const currentLabelMap = leftResultMap.get(name) || {};
|
|
101
108
|
leftSummaryColumnKeys.forEach(key => {
|
|
102
|
-
const cellValue = getCellValue(row, formulaRow, {
|
|
109
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
|
|
103
110
|
...leftSummaryColumn[key],
|
|
104
111
|
key
|
|
105
112
|
});
|
|
106
113
|
const currentLabelList = currentLabelMap[key] || [];
|
|
107
|
-
if (isNumber(cellValue)) {
|
|
114
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
108
115
|
currentLabelList.push(cellValue);
|
|
109
116
|
}
|
|
110
117
|
currentLabelMap[key] = currentLabelList;
|
|
@@ -115,12 +122,12 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
115
122
|
if (label.length === 0 && x_axis_include_empty) {
|
|
116
123
|
let currentValue = leftResultMap.get(null) || {};
|
|
117
124
|
leftSummaryColumnKeys.forEach(key => {
|
|
118
|
-
const cellValue = getCellValue(row, formulaRow, {
|
|
125
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
|
|
119
126
|
...leftSummaryColumn[key],
|
|
120
127
|
key
|
|
121
128
|
});
|
|
122
129
|
const currentLabelList = currentValue[key] || [];
|
|
123
|
-
if (isNumber(cellValue)) {
|
|
130
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
124
131
|
currentLabelList.push(cellValue);
|
|
125
132
|
}
|
|
126
133
|
currentValue[key] = currentLabelList;
|
|
@@ -131,12 +138,12 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
131
138
|
if (x_axis_include_empty || label) {
|
|
132
139
|
const currentValue = leftResultMap.get(label) || {};
|
|
133
140
|
leftSummaryColumnKeys.forEach(key => {
|
|
134
|
-
const cellValue = getCellValue(row, formulaRow, {
|
|
141
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
|
|
135
142
|
...leftSummaryColumn[key],
|
|
136
143
|
key
|
|
137
144
|
});
|
|
138
145
|
const currentList = currentValue[key] || [];
|
|
139
|
-
if (isNumber(cellValue)) {
|
|
146
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
140
147
|
currentList.push(cellValue);
|
|
141
148
|
}
|
|
142
149
|
currentValue[key] = currentList;
|
|
@@ -147,7 +154,7 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
// collect right y axis data
|
|
150
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.COUNT) {
|
|
157
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
151
158
|
if (isColumnDataAsAnArray) {
|
|
152
159
|
if (label.length > 0) {
|
|
153
160
|
label.forEach(name => {
|
|
@@ -169,13 +176,13 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
|
-
if (y_axis_right_summary_column && y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
173
|
-
const cellValue = getCellValue(row, formulaRow, column2);
|
|
179
|
+
if (y_axis_right_summary_column && y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
180
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, column2);
|
|
174
181
|
if (isColumnDataAsAnArray) {
|
|
175
182
|
if (label.length > 0) {
|
|
176
183
|
label.forEach(name => {
|
|
177
184
|
const currentLabelList = rightResultMap.get(name) || [];
|
|
178
|
-
if (isNumber(cellValue)) {
|
|
185
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
179
186
|
currentLabelList.push(cellValue);
|
|
180
187
|
}
|
|
181
188
|
rightResultMap.set(name, currentLabelList);
|
|
@@ -183,7 +190,7 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
183
190
|
}
|
|
184
191
|
if (label.length === 0 && x_axis_include_empty) {
|
|
185
192
|
let currentValue = rightResultMap.get(null) || [];
|
|
186
|
-
if (isNumber(cellValue)) {
|
|
193
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
187
194
|
currentValue.push(cellValue);
|
|
188
195
|
}
|
|
189
196
|
rightResultMap.set(null, currentValue);
|
|
@@ -191,7 +198,7 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
191
198
|
} else {
|
|
192
199
|
if (x_axis_include_empty || label) {
|
|
193
200
|
const currentLabelList = rightResultMap.get(label) || [];
|
|
194
|
-
if (isNumber(cellValue)) {
|
|
201
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
195
202
|
currentLabelList.push(cellValue);
|
|
196
203
|
}
|
|
197
204
|
rightResultMap.set(label, currentLabelList);
|
|
@@ -203,7 +210,7 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
203
210
|
// Summary collect data
|
|
204
211
|
let results = [];
|
|
205
212
|
let targetMap = leftResultMap;
|
|
206
|
-
if (leftSummaryColumnKeys.length === 0 && y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
213
|
+
if (leftSummaryColumnKeys.length === 0 && y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
207
214
|
targetMap = rightResultMap;
|
|
208
215
|
}
|
|
209
216
|
for (let item of targetMap) {
|
|
@@ -214,23 +221,23 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
214
221
|
let formattedValueLeft = value1;
|
|
215
222
|
let formattedValueRight = value2;
|
|
216
223
|
const rightValue = rightResultMap.get(key);
|
|
217
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.COUNT) {
|
|
224
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
218
225
|
value2 = rightValue;
|
|
219
226
|
formattedValueRight = value2;
|
|
220
227
|
}
|
|
221
|
-
if (y_axis_right_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
222
|
-
value2 = getSummaryResult(rightValue, y_axis_right_summary_method);
|
|
223
|
-
formattedValueRight =
|
|
228
|
+
if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
229
|
+
value2 = (0, _commonUtils.getSummaryResult)(rightValue, y_axis_right_summary_method);
|
|
230
|
+
formattedValueRight = _statUtils.default.getFormattedValue(value2, column2, y_axis_right_summary_method);
|
|
224
231
|
}
|
|
225
232
|
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
226
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.COUNT) {
|
|
233
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
227
234
|
value1 = leftValue;
|
|
228
235
|
formattedValueLeft = value1;
|
|
229
236
|
}
|
|
230
|
-
if (y_axis_left_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
237
|
+
if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
231
238
|
const list = leftValue[column1.key];
|
|
232
|
-
value1 = getSummaryResult(list, y_axis_left_summary_method);
|
|
233
|
-
formattedValueLeft =
|
|
239
|
+
value1 = (0, _commonUtils.getSummaryResult)(list, y_axis_left_summary_method);
|
|
240
|
+
formattedValueLeft = _statUtils.default.getFormattedValue(value1, column1, y_axis_left_summary_method);
|
|
234
241
|
}
|
|
235
242
|
results.push({
|
|
236
243
|
name: key,
|
|
@@ -244,8 +251,8 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
244
251
|
const summaryColumn = leftSummaryColumn[columnKey];
|
|
245
252
|
const summaryMethod = summaryColumn.method;
|
|
246
253
|
const list = leftValue[columnKey];
|
|
247
|
-
const value = getSummaryResult(list, summaryMethod);
|
|
248
|
-
formattedValueLeft =
|
|
254
|
+
const value = (0, _commonUtils.getSummaryResult)(list, summaryMethod);
|
|
255
|
+
formattedValueLeft = _statUtils.default.getFormattedValue(value, summaryColumn, summaryMethod);
|
|
249
256
|
results.push({
|
|
250
257
|
name: key,
|
|
251
258
|
value_left: value,
|
|
@@ -257,9 +264,9 @@ export default function calculateResult(chart, value, username, userId) {
|
|
|
257
264
|
});
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
|
-
|
|
267
|
+
_statUtils.default.sortStatistics(results, xAxisColumn, 'name');
|
|
261
268
|
results.forEach(item => {
|
|
262
|
-
item.name = getFormattedLabel(xAxisColumn, item.name, value.collaborators);
|
|
269
|
+
item.name = (0, _rowUtils.getFormattedLabel)(xAxisColumn, item.name, value.collaborators);
|
|
263
270
|
});
|
|
264
271
|
return results;
|
|
265
272
|
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
|
|
10
|
+
var _commonUtils = require("../../utils/common-utils");
|
|
11
|
+
var _rowUtils = require("../../utils/row-utils");
|
|
12
|
+
var _constants = require("../../constants");
|
|
6
13
|
function calculateChart(chart, value, username, userId) {
|
|
7
14
|
const {
|
|
8
15
|
table_id,
|
|
@@ -20,21 +27,21 @@ function calculateChart(chart, value, username, userId) {
|
|
|
20
27
|
} = chart;
|
|
21
28
|
const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
|
|
22
29
|
const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
|
|
23
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
24
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
30
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
31
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
25
32
|
if (!view || !x_axis_column_key) {
|
|
26
33
|
return [];
|
|
27
34
|
}
|
|
28
|
-
const groupbyColumn = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
35
|
+
const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
29
36
|
if (!groupbyColumn) {
|
|
30
37
|
return [];
|
|
31
38
|
}
|
|
32
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
33
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
34
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
39
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
40
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
41
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
35
42
|
const dateRangeResultMap = new Map();
|
|
36
43
|
const comparedDateRangeResultMap = new Map();
|
|
37
|
-
const isAdvance = y_axis_summary_type === SUMMARY_TYPE.ADVANCED;
|
|
44
|
+
const isAdvance = y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED;
|
|
38
45
|
statRows.forEach(row => {
|
|
39
46
|
const {
|
|
40
47
|
_id: rowId
|
|
@@ -43,11 +50,11 @@ function calculateChart(chart, value, username, userId) {
|
|
|
43
50
|
const formulaRow = formulaRows[rowId];
|
|
44
51
|
if (!cellValue) return;
|
|
45
52
|
if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end || cellValue >= x_axis_compared_date_range_start && cellValue <= x_axis_compared_date_range_end) {
|
|
46
|
-
const name =
|
|
53
|
+
const name = _statUtils.default.getGroupLabel(cellValue, formulaRow, groupbyColumn, x_axis_date_granularity, '', value);
|
|
47
54
|
if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end) {
|
|
48
55
|
if (isAdvance) {
|
|
49
56
|
const currentValue = dateRangeResultMap.get(name);
|
|
50
|
-
const _cellValue = getCellValue(row, formulaRow, summaryColumn);
|
|
57
|
+
const _cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, summaryColumn);
|
|
51
58
|
if (!currentValue) {
|
|
52
59
|
dateRangeResultMap.set(name, [_cellValue]);
|
|
53
60
|
} else {
|
|
@@ -64,7 +71,7 @@ function calculateChart(chart, value, username, userId) {
|
|
|
64
71
|
} else {
|
|
65
72
|
if (isAdvance) {
|
|
66
73
|
const currentValue = comparedDateRangeResultMap.get(name);
|
|
67
|
-
const _cellValue = getCellValue(row, formulaRow, summaryColumn);
|
|
74
|
+
const _cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, summaryColumn);
|
|
68
75
|
if (!currentValue && summaryColumn) {
|
|
69
76
|
comparedDateRangeResultMap.set(name, [_cellValue]);
|
|
70
77
|
} else {
|
|
@@ -89,8 +96,8 @@ function calculateChart(chart, value, username, userId) {
|
|
|
89
96
|
let value = item[1];
|
|
90
97
|
let formatted_value = value;
|
|
91
98
|
if (isAdvance) {
|
|
92
|
-
value = getSummaryResult(value, y_axis_summary_method, data.precision);
|
|
93
|
-
formatted_value =
|
|
99
|
+
value = (0, _commonUtils.getSummaryResult)(value, y_axis_summary_method, data.precision);
|
|
100
|
+
formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
94
101
|
}
|
|
95
102
|
dateRangeResult.push({
|
|
96
103
|
name: key,
|
|
@@ -100,14 +107,14 @@ function calculateChart(chart, value, username, userId) {
|
|
|
100
107
|
formatted_value
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
|
-
|
|
110
|
+
_statUtils.default.sortStatistics(dateRangeResult, groupbyColumn, 'name');
|
|
104
111
|
for (let item of comparedDateRangeResultMap) {
|
|
105
112
|
const key = item[0];
|
|
106
113
|
let value = item[1];
|
|
107
114
|
let formatted_value = value;
|
|
108
115
|
if (isAdvance) {
|
|
109
|
-
value = getSummaryResult(value, y_axis_summary_method, data.precision);
|
|
110
|
-
formatted_value =
|
|
116
|
+
value = (0, _commonUtils.getSummaryResult)(value, y_axis_summary_method, data.precision);
|
|
117
|
+
formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
111
118
|
}
|
|
112
119
|
comparedDateRangeResult.push({
|
|
113
120
|
name: key,
|
|
@@ -117,7 +124,7 @@ function calculateChart(chart, value, username, userId) {
|
|
|
117
124
|
formatted_value
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
|
-
|
|
127
|
+
_statUtils.default.sortStatistics(comparedDateRangeResult, groupbyColumn, 'name');
|
|
121
128
|
for (let i = 0; i < dateRangeResult.length; i++) {
|
|
122
129
|
if (!comparedDateRangeResult[i]) break;
|
|
123
130
|
comparedDateRangeResult[i].name = dateRangeResult[i].name;
|
|
@@ -136,4 +143,4 @@ function calculateChart(chart, value, username, userId) {
|
|
|
136
143
|
}
|
|
137
144
|
return [...comparedDateRangeResult, ...dateRangeResult];
|
|
138
145
|
}
|
|
139
|
-
|
|
146
|
+
var _default = exports.default = calculateChart;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 _commonUtils = require("../../utils/common-utils");
|
|
10
|
+
var _rowUtils = require("../../utils/row-utils");
|
|
11
|
+
var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
|
|
12
|
+
var _constants = require("../../constants");
|
|
6
13
|
function calculateResult(chart, value, username, userId) {
|
|
7
14
|
const {
|
|
8
15
|
table_id,
|
|
@@ -14,17 +21,17 @@ function calculateResult(chart, value, username, userId) {
|
|
|
14
21
|
date_granularity,
|
|
15
22
|
geolocation_granularity
|
|
16
23
|
} = chart;
|
|
17
|
-
const table = TableUtils.getTableById(value.tables, table_id);
|
|
18
|
-
const view = table && Views.getViewById(table.views, view_id);
|
|
24
|
+
const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
25
|
+
const view = table && _dtableStore.Views.getViewById(table.views, view_id);
|
|
19
26
|
if (!view) {
|
|
20
27
|
return [];
|
|
21
28
|
}
|
|
22
|
-
const nameColumn = TableUtils.getTableColumnByKey(table, name_column);
|
|
29
|
+
const nameColumn = _dtableStore.TableUtils.getTableColumnByKey(table, name_column);
|
|
23
30
|
if (!nameColumn) return [];
|
|
24
|
-
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
25
|
-
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
26
|
-
const groupColumn = TableUtils.getTableColumnByKey(table, group_column);
|
|
27
|
-
const isColumnDataAsAnArray = isArrayCellValue(nameColumn);
|
|
31
|
+
const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
|
|
32
|
+
const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
|
|
33
|
+
const groupColumn = _dtableStore.TableUtils.getTableColumnByKey(table, group_column);
|
|
34
|
+
const isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(nameColumn);
|
|
28
35
|
const isGroupChart = !!groupColumn;
|
|
29
36
|
let result = [];
|
|
30
37
|
if (!isGroupChart) {
|
|
@@ -36,18 +43,18 @@ function calculateResult(chart, value, username, userId) {
|
|
|
36
43
|
let formulaRow = formulaRows[rowId] || {};
|
|
37
44
|
const name = row[nameColumn.key];
|
|
38
45
|
if (name || Number.isFinite(name)) {
|
|
39
|
-
let label =
|
|
46
|
+
let label = _statUtils.default.getGroupLabel(name, formulaRow, nameColumn, '', '', value);
|
|
40
47
|
if (isColumnDataAsAnArray) {
|
|
41
48
|
label = label[0];
|
|
42
49
|
}
|
|
43
|
-
label = getFormattedLabel(nameColumn, label, value.collaborators);
|
|
50
|
+
label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
|
|
44
51
|
if (!memo.get(label)) {
|
|
45
|
-
const completedColumn = TableUtils.getTableColumnByKey(table, completed_column);
|
|
46
|
-
const targetColumn = TableUtils.getTableColumnByKey(table, target_column);
|
|
47
|
-
let currentValue = getCellValue(row, formulaRow, completedColumn);
|
|
48
|
-
let targetValue = getCellValue(row, formulaRow, targetColumn);
|
|
49
|
-
currentValue = isNumber(currentValue) ? currentValue : 0;
|
|
50
|
-
targetValue = isNumber(targetValue) ? targetValue : 0;
|
|
52
|
+
const completedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, completed_column);
|
|
53
|
+
const targetColumn = _dtableStore.TableUtils.getTableColumnByKey(table, target_column);
|
|
54
|
+
let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
|
|
55
|
+
let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
|
|
56
|
+
currentValue = (0, _dtableStore.isNumber)(currentValue) ? currentValue : 0;
|
|
57
|
+
targetValue = (0, _dtableStore.isNumber)(targetValue) ? targetValue : 0;
|
|
51
58
|
if (currentValue >= targetValue) {
|
|
52
59
|
result.unshift({
|
|
53
60
|
name: label,
|
|
@@ -79,8 +86,8 @@ function calculateResult(chart, value, username, userId) {
|
|
|
79
86
|
const memo = new Map();
|
|
80
87
|
const colorMap = {};
|
|
81
88
|
let colorIndex = 0;
|
|
82
|
-
let isFormulaType = FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
|
|
83
|
-
const isGroupColumnDataAsAnArray = isArrayCellValue(groupColumn);
|
|
89
|
+
let isFormulaType = _dtableStore.FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
|
|
90
|
+
const isGroupColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupColumn);
|
|
84
91
|
statRows.forEach(row => {
|
|
85
92
|
let {
|
|
86
93
|
_id: rowId
|
|
@@ -89,30 +96,30 @@ function calculateResult(chart, value, username, userId) {
|
|
|
89
96
|
const name = row[nameColumn.key],
|
|
90
97
|
groupLabelName = !isFormulaType ? row[groupColumn.key] : formulaRow[rowId][groupColumn.key];
|
|
91
98
|
if ((name || Number.isFinite(name)) && (groupLabelName || Number.isFinite(groupLabelName))) {
|
|
92
|
-
let label =
|
|
93
|
-
groupLabel =
|
|
99
|
+
let label = _statUtils.default.getGroupLabel(name, formulaRow, nameColumn, '', '', value),
|
|
100
|
+
groupLabel = _statUtils.default.getGroupLabel(groupLabelName, formulaRow, groupColumn, date_granularity, geolocation_granularity, value);
|
|
94
101
|
if (isColumnDataAsAnArray) {
|
|
95
102
|
label = label[0];
|
|
96
103
|
}
|
|
97
104
|
if (isGroupColumnDataAsAnArray) {
|
|
98
105
|
groupLabel = groupLabel[0];
|
|
99
106
|
}
|
|
100
|
-
label = getFormattedLabel(nameColumn, label, value.collaborators);
|
|
101
|
-
groupLabel = getFormattedLabel(groupColumn, groupLabel, value.collaborators);
|
|
107
|
+
label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
|
|
108
|
+
groupLabel = (0, _rowUtils.getFormattedLabel)(groupColumn, groupLabel, value.collaborators);
|
|
102
109
|
let color = colorMap[groupLabel];
|
|
103
110
|
if (!color) {
|
|
104
|
-
color = PIE_CHART_COLORS[colorIndex % 12];
|
|
111
|
+
color = _constants.PIE_CHART_COLORS[colorIndex % 12];
|
|
105
112
|
colorMap[groupLabel] = color;
|
|
106
113
|
colorIndex++;
|
|
107
114
|
}
|
|
108
115
|
let cache = memo.get(label);
|
|
109
116
|
if (groupLabel && (!cache || !cache[groupLabel])) {
|
|
110
|
-
const completedColumn = TableUtils.getTableColumnByKey(table, completed_column);
|
|
111
|
-
const targetColumn = TableUtils.getTableColumnByKey(table, target_column);
|
|
112
|
-
let currentValue = getCellValue(row, formulaRow, completedColumn);
|
|
113
|
-
let targetValue = getCellValue(row, formulaRow, targetColumn);
|
|
114
|
-
currentValue = isNumber(currentValue) ? currentValue : 0;
|
|
115
|
-
targetValue = isNumber(targetValue) ? targetValue : 0;
|
|
117
|
+
const completedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, completed_column);
|
|
118
|
+
const targetColumn = _dtableStore.TableUtils.getTableColumnByKey(table, target_column);
|
|
119
|
+
let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
|
|
120
|
+
let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
|
|
121
|
+
currentValue = (0, _dtableStore.isNumber)(currentValue) ? currentValue : 0;
|
|
122
|
+
targetValue = (0, _dtableStore.isNumber)(targetValue) ? targetValue : 0;
|
|
116
123
|
if (currentValue >= targetValue) {
|
|
117
124
|
result.unshift({
|
|
118
125
|
name: label,
|
|
@@ -157,4 +164,4 @@ function calculateResult(chart, value, username, userId) {
|
|
|
157
164
|
}
|
|
158
165
|
return result;
|
|
159
166
|
}
|
|
160
|
-
|
|
167
|
+
var _default = exports.default = calculateResult;
|
|
@@ -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, value, username, userId) {
|
|
5
11
|
const {
|
|
6
12
|
table_id,
|
|
@@ -10,17 +16,17 @@ function calculateResult(chart, value, username, userId) {
|
|
|
10
16
|
total_value_column,
|
|
11
17
|
total_value_column_summary_method
|
|
12
18
|
} = chart;
|
|
13
|
-
const selectedTable = TableUtils.getTableById(value.tables, table_id);
|
|
14
|
-
const selectedView = selectedTable && Views.getViewById(selectedTable.views, view_id);
|
|
15
|
-
const selectedColumn1 = TableUtils.getTableColumnByKey(selectedTable, target_value_column);
|
|
16
|
-
const selectedColumn2 = TableUtils.getTableColumnByKey(selectedTable, total_value_column);
|
|
17
|
-
const statRows = Views.getViewRows(selectedView, selectedTable, value, username, userId);
|
|
19
|
+
const selectedTable = _dtableStore.TableUtils.getTableById(value.tables, table_id);
|
|
20
|
+
const selectedView = selectedTable && _dtableStore.Views.getViewById(selectedTable.views, view_id);
|
|
21
|
+
const selectedColumn1 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, target_value_column);
|
|
22
|
+
const selectedColumn2 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, total_value_column);
|
|
23
|
+
const statRows = _dtableStore.Views.getViewRows(selectedView, selectedTable, value, username, userId);
|
|
18
24
|
if (statRows.length === 0) {
|
|
19
25
|
return 0;
|
|
20
26
|
}
|
|
21
|
-
const isNumericColumn1 = selectedColumn1 && isNumericColumn(selectedColumn1);
|
|
22
|
-
const isNumericColumn2 = selectedColumn2 && isNumericColumn(selectedColumn2);
|
|
23
|
-
const formulaRows = isNumericColumn1 || isNumericColumn2 ? Views.getTableFormulaResults(selectedTable, statRows, value) : {};
|
|
27
|
+
const isNumericColumn1 = selectedColumn1 && (0, _dtableStore.isNumericColumn)(selectedColumn1);
|
|
28
|
+
const isNumericColumn2 = selectedColumn2 && (0, _dtableStore.isNumericColumn)(selectedColumn2);
|
|
29
|
+
const formulaRows = isNumericColumn1 || isNumericColumn2 ? _dtableStore.Views.getTableFormulaResults(selectedTable, statRows, value) : {};
|
|
24
30
|
let result1;
|
|
25
31
|
let result2;
|
|
26
32
|
let numberList1 = [];
|
|
@@ -28,14 +34,14 @@ function calculateResult(chart, value, username, userId) {
|
|
|
28
34
|
statRows.forEach(row => {
|
|
29
35
|
const formulaRow = formulaRows[row._id];
|
|
30
36
|
if (isNumericColumn1) {
|
|
31
|
-
const cellValue1 = getCellValue(row, formulaRow, selectedColumn1);
|
|
32
|
-
if (isNumber(cellValue1)) {
|
|
37
|
+
const cellValue1 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn1);
|
|
38
|
+
if ((0, _dtableStore.isNumber)(cellValue1)) {
|
|
33
39
|
numberList1.push(cellValue1);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
if (isNumericColumn2) {
|
|
37
|
-
const cellValue2 = getCellValue(row, formulaRow, selectedColumn2);
|
|
38
|
-
if (isNumber(cellValue2)) {
|
|
43
|
+
const cellValue2 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn2);
|
|
44
|
+
if ((0, _dtableStore.isNumber)(cellValue2)) {
|
|
39
45
|
numberList2.push(cellValue2);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
@@ -43,16 +49,16 @@ function calculateResult(chart, value, username, userId) {
|
|
|
43
49
|
if (target_value_column_summary_method === 'Row_count') {
|
|
44
50
|
result1 = statRows.length;
|
|
45
51
|
} else {
|
|
46
|
-
result1 = getSummaryResult(numberList1, target_value_column_summary_method);
|
|
52
|
+
result1 = (0, _commonUtils.getSummaryResult)(numberList1, target_value_column_summary_method);
|
|
47
53
|
}
|
|
48
54
|
if (total_value_column_summary_method === 'Row_count') {
|
|
49
55
|
result2 = statRows.length;
|
|
50
56
|
} else {
|
|
51
|
-
result2 = getSummaryResult(numberList2, total_value_column_summary_method);
|
|
57
|
+
result2 = (0, _commonUtils.getSummaryResult)(numberList2, total_value_column_summary_method);
|
|
52
58
|
}
|
|
53
59
|
if (result2 === 0) {
|
|
54
60
|
return 0;
|
|
55
61
|
}
|
|
56
62
|
return result1 / result2;
|
|
57
63
|
}
|
|
58
|
-
|
|
64
|
+
var _default = exports.default = calculateResult;
|