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