dtable-statistic 4.2.2 → 4.3.1
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 +31 -37
- package/es/calculator/base-calculator.js +49 -99
- package/es/calculator/basic-chart-calculator.js +335 -559
- package/es/calculator/combination-calculator.js +231 -299
- package/es/calculator/compare-bar-calculator.js +184 -281
- package/es/calculator/completeness-calculator.js +203 -288
- package/es/calculator/copy-value.js +18 -18
- package/es/calculator/dashboard-calculator.js +68 -137
- package/es/calculator/heat-map-calculator.js +139 -220
- package/es/calculator/horizontal-bar-calculator.js +64 -93
- package/es/calculator/index.js +53 -69
- package/es/calculator/map-calculator.js +98 -174
- package/es/calculator/mirror-calculator.js +137 -216
- package/es/calculator/number-card-calculator.js +58 -126
- package/es/calculator/pivot-table-calculator.js +750 -792
- package/es/calculator/scatter-calculator.js +72 -140
- package/es/calculator/thread-manager.js +48 -67
- package/es/calculator/trend-calculator.js +107 -191
- package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
- package/es/calculator/workers/calculator.worker.js +22 -6
- package/es/calculator/workers/card-calculator-worker.js +16 -14
- package/es/calculator/workers/combination-calculator-worker.js +128 -135
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
- package/es/calculator/workers/completeness-calculator-worker.js +56 -49
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
- package/es/calculator/workers/mirror-calculator-worker.js +52 -52
- package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
- package/es/calculator/workers/scatter-calculator-worker.js +34 -32
- package/es/calculator/workers/trend-calculator-worker.js +33 -29
- package/es/calculator/world-map-calculator.js +120 -197
- package/es/components/common-add-tool.js +7 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
- package/es/components/dialog/color-theme-dialog.js +34 -47
- package/es/components/dialog/delete-confirmation-dialog.js +7 -5
- package/es/components/dialog/enlarged-chart-dialog.js +68 -81
- package/es/components/dialog/new-table-dialog.js +62 -80
- package/es/components/dialog/new-view-dialog.js +50 -62
- package/es/components/dialog/rename-view-dialog.js +49 -58
- package/es/components/dialog/statistic-record-dialog/index.js +233 -231
- package/es/components/dialog/statistic-types-dialog/index.js +40 -49
- package/es/components/dialog/table-select-dialog.js +61 -70
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
- package/es/components/dtable-popover.js +62 -81
- package/es/components/dtable-search-input.js +89 -99
- package/es/components/dtable-select.js +55 -74
- package/es/components/icon.js +5 -3
- package/es/components/loading.js +1 -1
- package/es/components/modal-portal.js +15 -32
- package/es/components/popover/color-rules/color-rule.js +137 -141
- package/es/components/popover/color-rules/index.js +58 -66
- package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
- package/es/components/popover/color-rules/rule-filters/index.js +50 -58
- package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
- package/es/components/popover/color-rules-popover.js +117 -121
- package/es/components/popover/color-selector-popover.js +60 -70
- package/es/components/seatable-radio/index.js +2 -2
- package/es/components/select/option-group.js +139 -157
- package/es/components/select/option.js +26 -40
- package/es/components/select/select.js +97 -112
- package/es/components/toast/alert.js +65 -80
- package/es/components/toast/index.js +1 -1
- package/es/components/toast/toast.js +76 -103
- package/es/components/toast/toastManager.js +57 -93
- package/es/components/toast/toaster.js +58 -56
- package/es/constants/color-rules.js +8 -5
- package/es/constants/dtable-select-style.js +44 -48
- package/es/constants/event-types.js +4 -4
- package/es/constants/index.js +328 -242
- package/es/constants/map.js +2 -2
- package/es/constants/model.js +20 -20
- package/es/constants/regions.js +1 -1
- package/es/constants/zIndexes.js +1 -1
- package/es/custom-g2.js +11 -11
- package/es/dashboard.js +343 -333
- package/es/desktop-dashboard.js +217 -224
- package/es/index.js +45 -58
- package/es/locale/index.js +3 -3
- package/es/locale/lang/de.js +1 -1
- package/es/locale/lang/en.js +7 -7
- package/es/locale/lang/fr.js +1 -1
- package/es/locale/lang/zh_CN.js +1 -1
- package/es/mobile-dashboard.js +76 -89
- package/es/model/bar-group.js +34 -44
- package/es/model/bar.js +26 -36
- package/es/model/base-model.js +11 -12
- package/es/model/basic-number-card.js +10 -20
- package/es/model/collaborators.js +10 -11
- package/es/model/combination.js +32 -42
- package/es/model/compare-bar.js +30 -40
- package/es/model/completeness-group.js +19 -29
- package/es/model/completeness.js +14 -24
- package/es/model/custom-bar.js +14 -24
- package/es/model/dashboard.js +9 -19
- package/es/model/generic-model.js +187 -197
- package/es/model/heat-map.js +16 -26
- package/es/model/horizontal-bar-group.js +32 -42
- package/es/model/horizontal-bar.js +26 -36
- package/es/model/index.js +31 -3
- package/es/model/map.js +20 -30
- package/es/model/mirror.js +15 -25
- package/es/model/pie.js +21 -31
- package/es/model/ring.js +23 -33
- package/es/model/scatter.js +11 -21
- package/es/model/statistic-dashboard.js +7 -8
- package/es/model/table.js +19 -29
- package/es/model/trend.js +15 -25
- package/es/model/world-map.js +17 -27
- package/es/service/chart-service.js +69 -65
- package/es/service/dashboard-service.js +421 -419
- package/es/service/map-json.js +112 -132
- package/es/stat-editor/chart-name-editor.js +44 -58
- package/es/stat-editor/index.js +59 -70
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
- package/es/stat-editor/stat-settings/map/map-level.js +31 -43
- package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
- package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
- package/es/stat-list/chart-preview.js +85 -98
- package/es/stat-list/index.js +170 -178
- package/es/stat-view/area-chart.js +282 -274
- package/es/stat-view/bar-chart.js +300 -292
- package/es/stat-view/base-chart.js +58 -52
- package/es/stat-view/basic-number-card.js +115 -168
- package/es/stat-view/combination-chart.js +298 -334
- package/es/stat-view/compare-chart.js +256 -254
- package/es/stat-view/completeness-chart.js +194 -206
- package/es/stat-view/custom-bar.js +221 -223
- package/es/stat-view/dashboard-chart.js +122 -180
- package/es/stat-view/heat-map.js +268 -294
- package/es/stat-view/horizontal-bar-chart.js +291 -281
- package/es/stat-view/index.js +136 -152
- package/es/stat-view/line-chart.js +267 -265
- package/es/stat-view/map.js +246 -246
- package/es/stat-view/mirror.js +141 -152
- package/es/stat-view/pie-chart.js +143 -156
- package/es/stat-view/pivot-table/index.js +113 -118
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
- package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
- package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
- package/es/stat-view/ring-chart.js +189 -200
- package/es/stat-view/scatter-chart.js +162 -213
- package/es/stat-view/treemap-chart.js +136 -200
- package/es/stat-view/trend-chart.js +137 -183
- package/es/stat-view/world-map.js +233 -243
- package/es/tabs/index.js +164 -169
- package/es/tabs/tab.js +101 -116
- package/es/utils/basic-chart-utils.js +7 -9
- package/es/utils/cell-format.js +48 -51
- package/es/utils/cell-value.js +1 -1
- package/es/utils/collaborator.js +15 -14
- package/es/utils/color-utils.js +48 -37
- package/es/utils/column-utils.js +47 -33
- package/es/utils/column.js +1 -1
- package/es/utils/common-utils.js +111 -117
- package/es/utils/date-format.js +17 -17
- package/es/utils/export-table-utils.js +507 -396
- package/es/utils/index.js +6 -6
- package/es/utils/map.js +30 -34
- package/es/utils/model.js +3 -5
- package/es/utils/object.js +4 -4
- package/es/utils/pivot-table.js +20 -20
- package/es/utils/row-utils.js +41 -33
- package/es/utils/search.js +18 -20
- package/es/utils/sql-utils.js +132 -98
- package/es/utils/stat-utils.js +303 -320
- package/es/utils/trend-utils.js +57 -67
- package/package.json +2 -2
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
1
|
import { CellType, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, TableUtils, Views } from 'dtable-store';
|
|
4
2
|
import { STATISTICS_COUNT_TYPE, STAT_TYPE, Y_AXIS_TYPE_PREFIX } from '../../constants';
|
|
5
3
|
import { getColorFromSingleSelectColumn } from '../../utils/column-utils';
|
|
@@ -7,33 +5,39 @@ import { isArrayCellValue } from '../../utils/common-utils';
|
|
|
7
5
|
import { getFormattedLabel, isValidRow } from '../../utils/row-utils';
|
|
8
6
|
import StatUtils from '../../utils/stat-utils';
|
|
9
7
|
import { fixMapGeoGranularity } from '../../utils/map';
|
|
10
|
-
|
|
8
|
+
const MAP_CHART_TYPES = [STAT_TYPE.MAP, STAT_TYPE.WORLD_MAP, STAT_TYPE.MAP_BUBBLE, STAT_TYPE.WORLD_MAP_BUBBLE];
|
|
11
9
|
function calculateChart(chart, value, username, userId) {
|
|
12
|
-
|
|
10
|
+
const {
|
|
11
|
+
type
|
|
12
|
+
} = chart;
|
|
13
13
|
if (MAP_CHART_TYPES.includes(type)) {
|
|
14
14
|
return calculateGeolocationBasicChart(chart, value, username, userId);
|
|
15
15
|
}
|
|
16
16
|
if (type === STAT_TYPE.CUSTOM_BAR) {
|
|
17
17
|
return calculateCustomBar(chart, value, username, userId);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const {
|
|
20
|
+
column_groupby_column_key,
|
|
21
|
+
column_groupby_multiple_numeric_column
|
|
22
|
+
} = chart;
|
|
21
23
|
if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
|
|
22
24
|
return calculateBasicChart(chart, value, username, userId);
|
|
23
25
|
}
|
|
24
26
|
return calculateGroupingChart(chart, value, username, userId);
|
|
25
27
|
}
|
|
26
28
|
function calculateBasicChart(chart, value, username, userId) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const {
|
|
30
|
+
table_id,
|
|
31
|
+
view_id,
|
|
32
|
+
sort_type
|
|
33
|
+
} = chart;
|
|
34
|
+
let groupby_column_key;
|
|
35
|
+
let summary_type;
|
|
36
|
+
let summary_method;
|
|
37
|
+
let summary_column_key;
|
|
38
|
+
let groupby_date_granularity;
|
|
39
|
+
let include_empty;
|
|
40
|
+
let groupby_geolocation_granularity;
|
|
37
41
|
if (chart.type === STAT_TYPE.PIE || chart.type === STAT_TYPE.RING || chart.type === STAT_TYPE.TREEMAP) {
|
|
38
42
|
groupby_column_key = chart.groupby_column_key;
|
|
39
43
|
summary_type = chart.summary_type;
|
|
@@ -51,97 +55,106 @@ function calculateBasicChart(chart, value, username, userId) {
|
|
|
51
55
|
groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
52
56
|
include_empty = chart.x_axis_include_empty;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const table = TableUtils.getTableById(value.tables, table_id);
|
|
59
|
+
const view = table && Views.getViewById(table.views, view_id);
|
|
56
60
|
if (!view) {
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
|
-
|
|
63
|
+
const groupbyColumn = groupby_column_key && TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
60
64
|
if (!groupbyColumn) {
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
68
|
+
const {
|
|
69
|
+
type: groupby_column_type
|
|
70
|
+
} = groupbyColumn;
|
|
65
71
|
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
66
72
|
groupby_date_granularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
67
73
|
}
|
|
68
74
|
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
69
75
|
groupby_geolocation_granularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const yAxisType = null;
|
|
78
|
+
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
79
|
+
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
80
|
+
const isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
81
|
+
let results = getBasicChartResults(statRows, formulaRows, groupbyColumn, include_empty, isGroupbyColumnDataAsAnArray, groupby_date_granularity, groupby_geolocation_granularity, summaryColumn, summary_type, summary_method, yAxisType, value);
|
|
76
82
|
if (sort_type) {
|
|
77
83
|
StatUtils.sortStatisticData(results, sort_type); // sortby statistic value
|
|
78
84
|
} else {
|
|
79
85
|
StatUtils.sortStatistics(results, groupbyColumn, 'name'); // sortby statistic label
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
results.forEach(
|
|
88
|
+
results.forEach(item => {
|
|
83
89
|
item.name = getFormattedLabel(groupbyColumn, item.name, value.collaborators);
|
|
84
90
|
});
|
|
85
91
|
return results;
|
|
86
92
|
}
|
|
87
93
|
function calculateGroupingChart(chart, value, username, userId) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
const {
|
|
95
|
+
table_id,
|
|
96
|
+
view_id,
|
|
97
|
+
x_axis_column_key,
|
|
98
|
+
x_axis_include_empty,
|
|
99
|
+
y_axis_column_key,
|
|
100
|
+
y_axis_summary_type,
|
|
101
|
+
y_axis_summary_method,
|
|
102
|
+
column_groupby_multiple_numeric_column
|
|
103
|
+
} = chart;
|
|
104
|
+
const groupby_column_key = x_axis_column_key;
|
|
105
|
+
const column_groupby_column_key = chart.column_groupby_column_key;
|
|
106
|
+
const column_groupby_date_granularity = chart.column_groupby_date_granularity;
|
|
107
|
+
const column_groupby_geolocation_granularity = chart.column_groupby_geolocation_granularity;
|
|
108
|
+
let groupby_date_granularity = chart.x_axis_date_granularity;
|
|
109
|
+
let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
110
|
+
let column_groupby_numeric_columns = chart.column_groupby_numeric_columns || [];
|
|
111
|
+
const table = TableUtils.getTableById(value.tables, table_id);
|
|
112
|
+
const view = table && Views.getViewById(table.views, view_id);
|
|
105
113
|
if (!view) {
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
|
-
|
|
116
|
+
const groupbyColumn = groupby_column_key && TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
109
117
|
if (!groupbyColumn) {
|
|
110
118
|
return;
|
|
111
119
|
}
|
|
112
|
-
|
|
120
|
+
const {
|
|
121
|
+
type: groupby_column_type
|
|
122
|
+
} = groupbyColumn;
|
|
113
123
|
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
114
124
|
groupby_date_granularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
115
125
|
}
|
|
116
126
|
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
117
127
|
groupby_geolocation_granularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
118
128
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
const yAxisType = null;
|
|
130
|
+
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
131
|
+
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
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);
|
|
123
133
|
StatUtils.sortStatistics(results, groupbyColumn, 'name');
|
|
124
|
-
results = results.map(
|
|
125
|
-
return
|
|
134
|
+
results = results.map(result => {
|
|
135
|
+
return {
|
|
136
|
+
...result,
|
|
126
137
|
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
127
|
-
}
|
|
138
|
+
};
|
|
128
139
|
});
|
|
129
140
|
return results;
|
|
130
141
|
}
|
|
131
142
|
function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
|
|
132
|
-
|
|
143
|
+
let columnGroupbyColumn = TableUtils.getTableColumnByKey(table, groupColumnKey);
|
|
133
144
|
if (!columnGroupbyColumn) {
|
|
134
145
|
return [];
|
|
135
146
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
statRows.forEach(
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
let result = [];
|
|
148
|
+
let isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
149
|
+
let isColumnGroupbyColumnDataAsAnArray = isArrayCellValue(columnGroupbyColumn);
|
|
150
|
+
statRows.forEach(row => {
|
|
151
|
+
let {
|
|
152
|
+
_id: rowId
|
|
153
|
+
} = row;
|
|
154
|
+
let formulaRow = formulaRows[rowId];
|
|
142
155
|
if (isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
let name = StatUtils.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
157
|
+
let groupName = columnGroupbyColumn.name;
|
|
145
158
|
if (!columnGroupbyMultipleNumericColumn) {
|
|
146
159
|
groupName = StatUtils.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, value);
|
|
147
160
|
}
|
|
@@ -149,7 +162,7 @@ function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, st
|
|
|
149
162
|
if (name.length === 0 && includeEmpty) {
|
|
150
163
|
groupChartRows(result, null, row, isColumnGroupbyColumnDataAsAnArray, groupName, includeEmpty, yAxisType);
|
|
151
164
|
} else {
|
|
152
|
-
name.forEach(
|
|
165
|
+
name.forEach(n => {
|
|
153
166
|
groupChartRows(result, n, row, isColumnGroupbyColumnDataAsAnArray, groupName, includeEmpty, yAxisType);
|
|
154
167
|
});
|
|
155
168
|
}
|
|
@@ -162,14 +175,14 @@ function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, st
|
|
|
162
175
|
return result;
|
|
163
176
|
}
|
|
164
177
|
function updateBasicChartRows(results, index, name, row, yAxisType) {
|
|
165
|
-
|
|
178
|
+
let updatedResult;
|
|
166
179
|
if (index > -1) {
|
|
167
180
|
updatedResult = results[index];
|
|
168
181
|
updatedResult.rows.push(row);
|
|
169
182
|
results[index] = updatedResult;
|
|
170
183
|
} else {
|
|
171
184
|
updatedResult = {
|
|
172
|
-
name
|
|
185
|
+
name,
|
|
173
186
|
rows: [row]
|
|
174
187
|
};
|
|
175
188
|
if (yAxisType) {
|
|
@@ -183,7 +196,7 @@ function groupChartRows(results, name, row, isColumnGroupbyColumnDataAsAnArray,
|
|
|
183
196
|
if (!groupName || groupName.length === 0) {
|
|
184
197
|
updateGroupingChartRows(results, name, null, row, yAxisType);
|
|
185
198
|
} else {
|
|
186
|
-
groupName.forEach(
|
|
199
|
+
groupName.forEach(v => {
|
|
187
200
|
updateGroupingChartRows(results, name, v, row, yAxisType);
|
|
188
201
|
});
|
|
189
202
|
}
|
|
@@ -195,21 +208,21 @@ function groupChartRows(results, name, row, isColumnGroupbyColumnDataAsAnArray,
|
|
|
195
208
|
}
|
|
196
209
|
}
|
|
197
210
|
function updateGroupingChartRows(results, name, groupName, row, yAxisType) {
|
|
198
|
-
|
|
199
|
-
for (
|
|
211
|
+
let updatedIndex = -1;
|
|
212
|
+
for (let i = 0; i < results.length; i++) {
|
|
200
213
|
if (results[i].name === name && results[i].group_name === groupName) {
|
|
201
214
|
updatedIndex = i;
|
|
202
215
|
break;
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
|
-
|
|
218
|
+
let updatedResult;
|
|
206
219
|
if (updatedIndex > -1) {
|
|
207
220
|
updatedResult = results[updatedIndex];
|
|
208
221
|
updatedResult.rows.push(row);
|
|
209
222
|
results[updatedIndex] = updatedResult;
|
|
210
223
|
} else {
|
|
211
224
|
updatedResult = {
|
|
212
|
-
name
|
|
225
|
+
name,
|
|
213
226
|
rows: [row],
|
|
214
227
|
group_name: groupName
|
|
215
228
|
};
|
|
@@ -220,64 +233,67 @@ function updateGroupingChartRows(results, name, groupName, row, yAxisType) {
|
|
|
220
233
|
}
|
|
221
234
|
}
|
|
222
235
|
function updateChartValue(summaryColumn, summary_type, summary_method, formula_rows) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
summaryColumnKey
|
|
226
|
-
summaryColumnType
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
236
|
+
let results = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
237
|
+
const {
|
|
238
|
+
key: summaryColumnKey,
|
|
239
|
+
type: summaryColumnType
|
|
240
|
+
} = summaryColumn || {};
|
|
241
|
+
Array.isArray(results) && results.forEach((item, index) => {
|
|
242
|
+
const {
|
|
243
|
+
rows
|
|
244
|
+
} = item;
|
|
245
|
+
let updated = {
|
|
246
|
+
...item
|
|
247
|
+
};
|
|
248
|
+
const value = StatUtils.getTotal(summaryColumnKey, summaryColumnType, summary_type, summary_method, rows, formula_rows);
|
|
231
249
|
updated.value = value;
|
|
232
250
|
updated.formatted_value = StatUtils.getFormattedValue(value, summaryColumn, summary_method);
|
|
233
251
|
results[index] = updated;
|
|
234
252
|
});
|
|
235
253
|
}
|
|
236
254
|
function getBasicChartResults(rows, formulaRows, groupbyColumn, includeEmpty, isGroupbyColumnDataAsAnArray, groupbyDateGranularity, groupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, yAxisType, value) {
|
|
237
|
-
|
|
238
|
-
rows.forEach(
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
let results = [];
|
|
256
|
+
rows.forEach(row => {
|
|
257
|
+
const {
|
|
258
|
+
_id: rowId
|
|
259
|
+
} = row;
|
|
260
|
+
const formulaRow = formulaRows[rowId];
|
|
241
261
|
if (!isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
242
|
-
|
|
262
|
+
const name = StatUtils.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
243
263
|
if (isGroupbyColumnDataAsAnArray) {
|
|
244
264
|
if (name.length === 0 && includeEmpty) {
|
|
245
|
-
|
|
246
|
-
return !result.name;
|
|
247
|
-
});
|
|
265
|
+
const nameIndex = results.findIndex(result => !result.name);
|
|
248
266
|
updateBasicChartRows(results, nameIndex, null, row, yAxisType);
|
|
249
267
|
} else {
|
|
250
|
-
name.forEach(
|
|
251
|
-
|
|
252
|
-
return n === result.name;
|
|
253
|
-
});
|
|
268
|
+
name.forEach(n => {
|
|
269
|
+
const nameIndex = results.findIndex(result => n === result.name);
|
|
254
270
|
updateBasicChartRows(results, nameIndex, n, row, yAxisType);
|
|
255
271
|
});
|
|
256
272
|
}
|
|
257
273
|
} else {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
261
|
-
updateBasicChartRows(results, _nameIndex, name, row, yAxisType);
|
|
274
|
+
const nameIndex = results.findIndex(result => result.name === name);
|
|
275
|
+
updateBasicChartRows(results, nameIndex, name, row, yAxisType);
|
|
262
276
|
}
|
|
263
277
|
});
|
|
264
278
|
updateChartValue(summaryColumn, summaryType, summaryMethod, formulaRows, results);
|
|
265
279
|
return results;
|
|
266
280
|
}
|
|
267
281
|
function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, yAxisColumnKey, yAxisSummaryType, yAxisSummaryMethod, isColumnGroupbyNumericColumns, columnGroupbyNumericColumns, yAxisType, table, value) {
|
|
268
|
-
|
|
282
|
+
let results = [];
|
|
269
283
|
if (isColumnGroupbyNumericColumns) {
|
|
270
|
-
|
|
284
|
+
let allColumnGroupbyNumericColumns = [{
|
|
271
285
|
column_key: yAxisColumnKey,
|
|
272
286
|
summary_method: yAxisSummaryMethod
|
|
273
287
|
}];
|
|
274
288
|
if (Array.isArray(columnGroupbyNumericColumns) && columnGroupbyNumericColumns.length > 0) {
|
|
275
|
-
allColumnGroupbyNumericColumns.push
|
|
289
|
+
allColumnGroupbyNumericColumns.push(...columnGroupbyNumericColumns);
|
|
276
290
|
}
|
|
277
|
-
allColumnGroupbyNumericColumns.forEach(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
291
|
+
allColumnGroupbyNumericColumns.forEach(numericSummaryColumn => {
|
|
292
|
+
const {
|
|
293
|
+
column_key: summary_column_key,
|
|
294
|
+
summary_method
|
|
295
|
+
} = numericSummaryColumn;
|
|
296
|
+
const currentResults = getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, yAxisSummaryType, summary_method, yAxisType, table, value);
|
|
281
297
|
results = results.concat(currentResults);
|
|
282
298
|
});
|
|
283
299
|
} else {
|
|
@@ -286,13 +302,15 @@ function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeE
|
|
|
286
302
|
return results;
|
|
287
303
|
}
|
|
288
304
|
function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumnKey, summaryType, summaryMethod, yAxisType, table, value) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
results = results.map(
|
|
294
|
-
|
|
295
|
-
|
|
305
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, summaryColumnKey);
|
|
306
|
+
const columnGroupbyMultipleNumericColumn = false;
|
|
307
|
+
let results = getGroupChartStatResult(table, value, groupbyColumn, columnGroupbyColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
308
|
+
const columnGroupByColumn = TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
309
|
+
results = results.map(result => {
|
|
310
|
+
const groupName = result.group_name;
|
|
311
|
+
let formattedResult = {
|
|
312
|
+
...result
|
|
313
|
+
};
|
|
296
314
|
if (columnGroupByColumn.type == CellType.SINGLE_SELECT) {
|
|
297
315
|
formattedResult.color = getColorFromSingleSelectColumn(columnGroupByColumn, groupName);
|
|
298
316
|
}
|
|
@@ -302,46 +320,50 @@ function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, inclu
|
|
|
302
320
|
return results;
|
|
303
321
|
}
|
|
304
322
|
function getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, numericSummaryColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryType, summaryMethod, yAxisType, table, value) {
|
|
305
|
-
|
|
306
|
-
|
|
323
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, numericSummaryColumnKey);
|
|
324
|
+
const columnGroupbyMultipleNumericColumn = true;
|
|
307
325
|
return getGroupChartStatResult(table, value, groupbyColumn, numericSummaryColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
308
326
|
}
|
|
309
327
|
function calculateGeolocationBasicChart(chart, value, username, userId) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
328
|
+
const {
|
|
329
|
+
type,
|
|
330
|
+
table_id,
|
|
331
|
+
view_id,
|
|
332
|
+
geo_column,
|
|
333
|
+
summary_type,
|
|
334
|
+
summary_column,
|
|
335
|
+
summary_method
|
|
336
|
+
} = chart;
|
|
337
|
+
const table = TableUtils.getTableById(value.tables, table_id);
|
|
338
|
+
const view = table && Views.getViewById(table.views, view_id);
|
|
319
339
|
if (!view) {
|
|
320
340
|
return;
|
|
321
341
|
}
|
|
322
|
-
|
|
342
|
+
const geoColumn = geo_column && TableUtils.getTableColumnByKey(table, geo_column);
|
|
323
343
|
if (!geoColumn) {
|
|
324
344
|
return;
|
|
325
345
|
}
|
|
326
|
-
|
|
346
|
+
let geolocationGranularity = null;
|
|
327
347
|
if (type && type.includes('world')) {
|
|
328
348
|
geolocationGranularity = geoColumn.type === CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
329
349
|
} else {
|
|
330
350
|
geolocationGranularity = fixMapGeoGranularity(chart);
|
|
331
351
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
statRows.forEach(
|
|
338
|
-
|
|
339
|
-
|
|
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);
|
|
355
|
+
const geoColumnType = geoColumn.type;
|
|
356
|
+
let results = [];
|
|
357
|
+
statRows.forEach(row => {
|
|
358
|
+
const {
|
|
359
|
+
_id: rowId
|
|
360
|
+
} = row;
|
|
361
|
+
const formulaRow = formulaRows[rowId];
|
|
340
362
|
if (isValidRow(row, formulaRow, geoColumn, false)) {
|
|
341
363
|
if (FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
342
|
-
|
|
343
|
-
list.forEach(
|
|
344
|
-
|
|
364
|
+
const list = formulaRow[geoColumn.key];
|
|
365
|
+
list.forEach(n => {
|
|
366
|
+
const nameIndex = results.findIndex(r => {
|
|
345
367
|
if (geolocationGranularity) {
|
|
346
368
|
return n[geolocationGranularity] === r.name;
|
|
347
369
|
}
|
|
@@ -354,13 +376,11 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
|
|
|
354
376
|
}
|
|
355
377
|
});
|
|
356
378
|
} else {
|
|
357
|
-
|
|
379
|
+
let name = row[geoColumn.key] || null;
|
|
358
380
|
if (name && geolocationGranularity) {
|
|
359
381
|
name = name[geolocationGranularity];
|
|
360
382
|
}
|
|
361
|
-
|
|
362
|
-
return r.name === name;
|
|
363
|
-
});
|
|
383
|
+
const nameIndex = results.findIndex(r => r.name === name);
|
|
364
384
|
updateBasicChartRows(results, nameIndex, name, row, null);
|
|
365
385
|
}
|
|
366
386
|
}
|
|
@@ -369,58 +389,67 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
|
|
|
369
389
|
return results;
|
|
370
390
|
}
|
|
371
391
|
function calculateCustomBar(statItem, value, username, userId) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
392
|
+
const {
|
|
393
|
+
table_id,
|
|
394
|
+
view_id,
|
|
395
|
+
x_axis_column_key,
|
|
396
|
+
x_axis_date_granularity,
|
|
397
|
+
x_axis_geolocation_granularity,
|
|
398
|
+
x_axis_include_empty,
|
|
399
|
+
y_axises
|
|
400
|
+
} = statItem;
|
|
401
|
+
const table = TableUtils.getTableById(value.tables, table_id);
|
|
402
|
+
const view = table && Views.getViewById(table.views, view_id);
|
|
381
403
|
if (!view || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
|
|
382
404
|
return [];
|
|
383
405
|
}
|
|
384
|
-
|
|
406
|
+
const groupbyColumn = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
385
407
|
if (!groupbyColumn) {
|
|
386
408
|
return [];
|
|
387
409
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
410
|
+
const {
|
|
411
|
+
type: groupbyColumnType
|
|
412
|
+
} = groupbyColumn;
|
|
413
|
+
let groupbyDateGranularity = x_axis_date_granularity;
|
|
414
|
+
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
391
415
|
if (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
|
|
392
416
|
groupbyDateGranularity = STATISTICS_COUNT_TYPE.MONTH;
|
|
393
417
|
}
|
|
394
418
|
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
395
419
|
groupbyGeolocationGranularity = STATISTICS_COUNT_TYPE.PROVINCE;
|
|
396
420
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
y_axises.forEach(
|
|
403
|
-
|
|
404
|
-
|
|
421
|
+
const columnGroupbyDateGranularity = null;
|
|
422
|
+
const columnGroupbyGeolocationGranularity = null;
|
|
423
|
+
const statRows = Views.getViewRows(view, table, value, username, userId);
|
|
424
|
+
const formulaRows = Views.getTableFormulaResults(table, statRows, value);
|
|
425
|
+
let results = [];
|
|
426
|
+
y_axises.forEach((yAxis, index) => {
|
|
427
|
+
const {
|
|
428
|
+
type: yAxisType,
|
|
429
|
+
column_groupby_numeric_columns
|
|
430
|
+
} = yAxis;
|
|
405
431
|
if (yAxisType === STAT_TYPE.BAR_STACK) {
|
|
406
432
|
// just support summary numeric columns.
|
|
407
433
|
if (!Array.isArray(column_groupby_numeric_columns) || column_groupby_numeric_columns.length === 0) {
|
|
408
434
|
return;
|
|
409
435
|
}
|
|
410
|
-
|
|
411
|
-
column_groupby_numeric_columns.forEach(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
436
|
+
const yAxisType = "".concat(Y_AXIS_TYPE_PREFIX).concat(index);
|
|
437
|
+
column_groupby_numeric_columns.forEach(numericSummaryColumn => {
|
|
438
|
+
const {
|
|
439
|
+
column_key: summary_column_key,
|
|
440
|
+
summary_method
|
|
441
|
+
} = numericSummaryColumn;
|
|
442
|
+
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, STATISTICS_COUNT_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
415
443
|
results = results.concat(currentResults);
|
|
416
444
|
});
|
|
417
445
|
}
|
|
418
446
|
});
|
|
419
447
|
StatUtils.sortStatistics(results, groupbyColumn, 'name');
|
|
420
|
-
results = results.map(
|
|
421
|
-
return
|
|
448
|
+
results = results.map(result => {
|
|
449
|
+
return {
|
|
450
|
+
...result,
|
|
422
451
|
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
423
|
-
}
|
|
452
|
+
};
|
|
424
453
|
});
|
|
425
454
|
return results;
|
|
426
455
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
var _typeCalculatorWorker;
|
|
3
1
|
import { expose } from 'comlink';
|
|
4
2
|
import PivotTableCalculatorWorker from './pivot-table-calculator-worker';
|
|
5
3
|
import BasicChartCalculatorWorker from './basic-chart-calculator-worker';
|
|
@@ -12,11 +10,29 @@ import CardCalculatorWorker from './card-calculator-worker';
|
|
|
12
10
|
import TrendCalculatorWorker from './trend-calculator-worker';
|
|
13
11
|
import DashboardCalculatorWorker from './dashboard-calculator-worker';
|
|
14
12
|
import { STAT_TYPE } from '../../constants';
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const BASIC_CHART = 'basic_chart';
|
|
14
|
+
const typeCalculatorWorkerMap = {
|
|
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
|
|
32
|
+
};
|
|
17
33
|
function calculator(chart, value, username, userId) {
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
const type = chart.type;
|
|
35
|
+
const calculatorWorker = typeCalculatorWorkerMap[type] || typeCalculatorWorkerMap[BASIC_CHART];
|
|
20
36
|
return calculatorWorker(chart, value, username, userId);
|
|
21
37
|
}
|
|
22
38
|
expose(calculator);
|