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